SpringMVC与HTML页面
springMVC返回html页面
spring-mvc.xml配置:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/html/" p:suffix=".html" />
Java代码:
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String toAddTest() {
return "addTest";
}
tomcat下测试一直是404
在web.xml中:
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
SpringMVC访问html页面(spring 拦截器将其拦截,需配置静态资源)
spring-MVC配置文件:
<mvc:resources location="/html/" mapping="/html/*.html"/>