[英]Why am I getting a 404 error with my Spring MVC project?
I have very basic setup for a spring mvc web application. 我有一个针对Spring MVC Web应用程序的非常基本的设置。 Here is my web.xml mapping below:
这是下面的我的web.xml映射:
<servlet>
<servlet-name>test</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
and spring-config.xml 和spring-config.xml
<mvc:default-servlet-handler/>
<mvc:annotation-driven />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<context:component-scan base-package="cz.dmostek"/>
<context:annotation-config/>
and this is my directory structure for the jsp pages 这是我的jsp页面的目录结构
`-- web
`-- WEB-INF
|-- pages
| |-- css
| | |-- foundation.css
| | `-- normalize.css
| |-- images
| |-- index.jsp
| `-- js
`-- web.xml
and my controller is declared below: 我的控制器声明如下:
@Controller
public class TestController {
@RequestMapping(value = "/")
public String
return "index";
}
}
However, when i try to access localhost:8080/app/ I got 404 error. 但是,当我尝试访问localhost:8080 / app /时,出现404错误。 In the log I have 2013-10-19
16:12:09,326 () DEBUG DispatcherServlet - Successfully completed request
在日志中,我有2013-10-19
16:12:09,326 () DEBUG DispatcherServlet - Successfully completed request
and if i debug the app everything seems ok, controller is called, view is rendered, but i am still getting 404. What do you think? 如果我调试该应用程序,一切似乎都正常,将调用控制器,呈现视图,但我仍会收到404。您怎么看?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.