SpringMVC - 问题. No mapping found for HTTP request with URI

  <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,布布扣,bubuko.com

SpringMVC - 问题. No mapping found for HTTP request with URI

上一篇:Android获取当前系统语言


下一篇:【转】Android版本升级同时Sqlite数据库的升级及之前数据的保留