<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/html/" />
<property name="suffix" value=".html" />
</bean>
这个配置用于SpringMVC跳转控制。
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
如果是静态资源如 css js html... 。InternalResourceViewResolver 不会解析资源,而是当作一个url被DispatcherServlet 拦截到..
如
@RequestMapping(value = "/")
public String login() {
return "login";
}
localhost:8080/demo/login.html 这时就会报 No mapping found for HTTP request with URI
解决办法
<mvc:default-servlet-handler/>
SpringMVC - 问题. No mapping found for HTTP request with URI