I was trying to add some HTML files to the spring project that I was working on. Initially, the project was working fine with JSP files.
This is the folder structure that I'm following: /WEB-INF/views/jsp/hello.jsp
Spring web configuration is as follows:
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/views/jsp");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
I tried to replace it with HTML as follows:
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/static/html/");
viewResolver.setSuffix(".html");
return viewResolver;
}
And the request mapping is as follows:
@RequestMapping(value = "/", method = RequestMethod.GET)
public String myMethod(ModelMap model) {
return "index";
}
Everything is working fine as long as the page is a JSP file. When changed to HTML, it'll start giving errors.
This is the log entry:
15-Dec-2016 11:54:57.408 WARNING [http-apr-9999-exec-2] org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/WEB-INF/views/html/index.html] in DispatcherServlet with name 'dispatcher'