小编avr*_*rao的帖子

Spring mvc 3.1 tomcat 7 - 404不解析jsp但控制器注释工作正常

我已经在这方面工作了一段时间,根本不知道出了什么问题.我正在Tomcat 7上部署Spring 3.1 MVC应用程序.从查看DEBUG输出,我可以看到1)MVC调度程序servlet根据需要获取所有URL 2)映射到控制器注释的任何URL工作正常3)任何URL需要映射到JSP得到404.另外,我使用的是JDK 1.7.0_09.我的JSP页面位于/ WEB-INF/jsp /中.

提前感谢我可能缺少的任何提示!

这是我的web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<web-app 
    id="WebApp_ID" 
    version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="
        http://java.sun.com/xml/ns/javaee 
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <display-name></display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)

我尝试将我的网址格式修改为/,/ ,/.,.到目前为止,"/"似乎占据了我最远的地步.此外,我可能是错的,但我不认为URL是问题,因为DEBUG日志显示所有的URL都转到调度程序servlet - 这就是我想要的.

这是我的dispatcher-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">

    <!--Tell the servlet where to look for annotated methods-->
    <context:component-scan base-package="com.test.web.mvc.ctrl" />

    <!--Enables many annotations and searches for …
Run Code Online (Sandbox Code Playgroud)

java model-view-controller spring jsp http-status-code-404

5
推荐指数
1
解决办法
3510
查看次数