Java 404针对弹簧应用的tomcat 6的错误

Java 404针对弹簧应用的tomcat 6的错误,java,spring,tomcat6,web.xml,Java,Spring,Tomcat6,Web.xml,我的应用程序已正确部署,但出现404错误。 无法找到正在发生的事情。 在此中,部署的意味着将我的webapp文件夹指向计算机中的位置 使用的URL: 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"

我的应用程序已正确部署,但出现404错误。 无法找到正在发生的事情。 在此中,部署的意味着将我的webapp文件夹指向计算机中的位置

使用的URL:

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>
<Context path="/studentspringmvc"
  docBase="/home/shoaib/Documents/myprograms/studentspringmvc/src/main/webapp" 
 reloadable="true" 
/>

SpringMVC应用程序
上下文配置位置
classpath*:applicationContext.xml
mvc调度器
org.springframework.web.servlet.DispatcherServlet
1.
mvc调度器
/
org.springframework.web.context.ContextLoaderListener
index.html
现在我在conf/Catalina/localhost文件夹中添加了studentspringmvc.xml,如下所示

studentspringmvc.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>
<Context path="/studentspringmvc"
  docBase="/home/shoaib/Documents/myprograms/studentspringmvc/src/main/webapp" 
 reloadable="true" 
/>

无法找到至少index.html未加载的原因。

您的dispatcher servlet映射到
/
。这意味着每个URL都映射到此servlet(包括index.html)。要确保仍然提供静态文件,需要启用默认servlet处理程序,如中所述:



您是否检查了tomcat日志?它说什么?没有错误,部署成功。可能是我触发了错误的url或提到了错误的url模式。我上传了一张新的图片,显示studentspringmvc true。这个applicationContext.xml文件到底在哪里?WEB-INF…没有问题。它找到了applicationContext.xml文件和所有文件。您是否在eclipse内部部署tomcat?如果是,那么您的上下文应该包含source=“org.eclipse.jst.jee.server:PROJECTNAME”,但添加这一行“我的控件”并不会进入控制器。