有一个示例应用程序并创建了一个
view/HelloWorld.html
页。从我的控制器,我返回以下
public String home(Locale locale, Model model) {
return "HelloWorld";
}
在调试模式下,我收到此警告/错误:
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/HelloWorld/WEB-INF/views/HelloWorld.html] in DispatcherServlet with name 'appServlet'
我的 src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml 的内容
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".html" />
</beans:bean>
如果我将 .html 重命名为 .jsp 并将上面的更改为 .jsp ,那么一切正常。