I have a problem with mine mappings. I have a template resolver which has the following configuration:
@Bean(name="templateResolver")
public ServletContextTemplateResolver getServletContextTemplateResolver() {
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
templateResolver.setPrefix("/WEB-INF/views/");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode("HTML5");
templateResolver.setCharacterEncoding("UTF-8");
templateResolver.setCacheable(false);
return templateResolver;
}
@Bean(name="templateEngine")
public SpringTemplateEngine getTemplateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(getServletContextTemplateResolver());
return templateEngine;
}
@Bean(name="viewResolver")
public ThymeleafViewResolver getThymeleafViewResolver() {
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(getTemplateEngine());
viewResolver.setOrder(1);
viewResolver.setCharacterEncoding("UTF-8");
return viewResolver;
}
And I have a structure of my project:
-WEB-INF
--views
---home.html
---registration.html
I'm using thymeleaf and spring 4.0. For home, I have added the following requestMapping in my controller:
@RequestMapping(value = "/", method = RequestMethod.GET)
public String start(Model model) {
return "home";
}
I don't have request mapping for registration.html.
In my home.html I have following link (thymeleaf anchor tag):
<a href="registration.html" th:href="@{/registration.html}" th:text="#{navigation.registration}">Registration</a>
I have binded my app in tomcat under /myapp and when I enter on /myapp I get the home.html page (I have a request mapping for that), but when I enter on /myapp/registration.html i get 404.
What I must do, to serve such static html files without adding every page to the controller? Is it possible? I tried with static resources but it doesn't work.
I also tried to move views directory level up so I had structure:
-WEB-INF
-views
--home.html
--registration.html
and I was able to enter on /myapp/views/registration.html, but I couldn't get into /myapp/registration.html