【发布时间】:2014-03-12 16:23:53
【问题描述】:
我的应用已正确部署,但出现 404 错误。 无法找到正在发生的事情。 在此已部署意味着将我的 webapp 文件夹指向计算机中的位置。
使用的网址:
localhost:8080/studentspringmvc/
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Spring MVC Application</display-name>
<context-param>
<param-name>contextConfigLocations</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
现在我在 conf/Catalina/localhost 文件夹中添加了 studentspringmvc.xml
studentspringmvc.xml
<Context path="/studentspringmvc"
docBase="/home/shoaib/Documents/myprograms/studentspringmvc/src/main/webapp"
reloadable="true"
/>
无法找到至少 index.html 未加载的原因。
【问题讨论】:
-
你检查过tomcat日志吗?它说什么?
-
没有错误部署成功。可能是我触发了错误的 url 或提到了错误的 url 模式。我已经上传了显示 studentspringmvc true 的新图片。
-
这个 applicationContext.xml 文件到底在哪里?
-
WEB-INF .....没问题。它找到了 applicationContext.xml 文件和所有文件。
-
你是在eclipse里面的tomcat上部署的吗?如果是,那么您的 Context 应该包含 source="org.eclipse.jst.jee.server:PROJECTNAME"
标签: java spring tomcat6 web.xml