Here is my view resolver:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".html"/>
</bean>
I also have a controller that should return hello.html:
@Controller
@RequestMapping("/")
public class IndexController {
@RequestMapping(method = RequestMethod.GET)
public String getHtmlPage() {
return "hello";
}
}
When I access localhost:8080 I get an error message:
WARNING: No mapping found for HTTP request with URI [/WEB-INF/pages/hello.html] in DispatcherServlet with name 'mvc-dispatcher'
Now when I change my suffix value to .jsp, then hello.jsp is returned correctly.
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
hello.jsp and hello.html are in the same folder. Any ideas how to fix this?
EDIT:
For html you don't need view resolvers. Instead just create a folder in your webapp folder.
Call it static
for example , then add <mvc:resources mapping="/static/**" location="/static/" />
to your xml.
In controller instead of return "hello";
put return "static/hello.html";