Ich versuche, eine Webanwendung mit Spring Boot und Thymeleaf zu erstellen, und habe Probleme beim Abrufen der in einer Eigenschaftendatei definierten Nachrichten. Statt der in der Eigenschaftendatei definierten Nachricht wird stattdessen ??form.welcome_en_GB??
angezeigt. Die Konsole protokolliert keine Fehler.Spring Boot + Thymeleaf finde keine Nachrichteneigenschaften
Die Projektstruktur ist wie folgt
src/main/java
- com.package
- controller
- FormController.java
- Application.java
- ServletInitializer.java
src/main/resources
- static
- home.html
- templates
- form.html
- form.properties
- application.properties
pom.xml
Application.java
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
ServletInitializer.java
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
FormController.java
@Controller
@RequestMapping("/form")
public class FormController {
private static final Logger log = LoggerFactory.getLogger(FormController.class);
@RequestMapping(value = "/new", method = RequestMethod.GET)
public ModelAndView getNewReportForm() {
log.info("New form requested");
ModelAndView mav = new ModelAndView("form");
return mav;
}
}
form.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<p th:text="#{form.welcome}">Welcome!</p>
</body>
</html>
form.properties
form.welcome=Hello there!
Danke, ich die Basisnamen für die Nachrichtenquelle gesetzt und seine Arbeits jetzt – SelketDaly