Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse HTTP 404错误:(/SpringMVC/)ressource不可用_Eclipse_Tomcat_Spring Mvc - Fatal编程技术网

Eclipse HTTP 404错误:(/SpringMVC/)ressource不可用

Eclipse HTTP 404错误:(/SpringMVC/)ressource不可用,eclipse,tomcat,spring-mvc,Eclipse,Tomcat,Spring Mvc,我安装了: -eclipse Indigo 3.7, -JDK 1.7 in /usr/lib/jvm` and, -Tomcat 7 -Spring framework 2.5.6 我想做一个教程 为此,我用«spring MVC framework»创建了一个«动态web项目»。我试图在服务器上运行它,但出现了一个«HTTP404错误:(/SpringMVC/)ressource不可用»。我真的不知道我错过了什么。提前感谢您的帮助 这些是我最初在项目中包括的图书馆: -jakarta-co

我安装了:

-eclipse Indigo 3.7,
-JDK 1.7 in /usr/lib/jvm` and,
-Tomcat 7
-Spring framework 2.5.6
我想做一个教程

为此,我用«spring MVC framework»创建了一个«
动态web项目
»。我试图在服务器上运行它,但出现了一个«
HTTP404错误:(/SpringMVC/)ressource不可用
»。我真的不知道我错过了什么。提前感谢您的帮助

这些是我最初在项目中包括的图书馆:

-jakarta-commons/commons-logging.jar
-mysql-connector-java-5.1.18
-j2ee/jstl.jar
-log4j/log4j-1.2.14.jar
-jakarta-taglibs/standard.jar
-dist/spring.jar
-dist/modules/spring-webmvc.jar
我刚刚添加了
springweb.jar

这是我收到的新错误消息:

nov. 22, 2011 7:48:15 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\QuickTime\QTSystem\;C:\MinGW\bin\;C:\MinGW\MSYS\1.0\local\bin\;C:\MinGW\MSYS\1.0\bin\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Eclipse\eclipse;;.
    nov. 22, 2011 7:48:16 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SpringMVC' did not find a matching property.
    nov. 22, 2011 7:48:16 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["http-bio-8080"]
    nov. 22, 2011 7:48:16 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
    nov. 22, 2011 7:48:16 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 571 ms
    nov. 22, 2011 7:48:16 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    nov. 22, 2011 7:48:16 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.21
    nov. 22, 2011 7:48:16 PM org.apache.catalina.core.ApplicationContext log
    INFO: Set web app root system property: 'webapp.root' = [C:\Users\cProg\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpringMVC\]
    nov. 22, 2011 7:48:16 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing log4j from [C:\Users\cProg\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpringMVC\WEB-INF\log4j.xml]
    nov. 22, 2011 7:48:16 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    nov. 22, 2011 7:48:17 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring FrameworkServlet 'springapp'
    nov. 22, 2011 7:48:17 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler ["http-bio-8080"]
    nov. 22, 2011 7:48:17 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler ["ajp-bio-8009"]
    nov. 22, 2011 7:48:17 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 1653 ms
我有4个xml文件:

-applicationContext.xml
-web.xml
-springapp-servlet.xml
-log4j.xml
它们的源代码是:

applicationContext.xml

<!--applicationContext.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!-- The Dao class -->
<bean id="studentDao" class="com.oyejava.springmvc.StudentJdbcDao">
    <property name="simpleJdbcTemplate" ref="jdbcTemplate" />
</bean>

<!-- Template class to access JDBC code -->
<bean id="jdbcTemplate"
    class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
    <constructor-arg ref="dataSource" />
</bean>

<!-- Configuration for the data source -->
<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <!-- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />-->
    <property name="url" value="jdbc:mysql://localhost:3306" />
    <!-- <property name="url" value="jdbc:hsqldb:hsql://localhost" />-->
    <property name="username" value="root" />
    <property name="password" value="" />
</bean>
</beans>
<!--log4j.xml-->

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <!-- Appenders -->
    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <param name="Threshold" value="info" />
        <param name="Target" value="System.out" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{ABSOLUTE} [%t] %-5p %c{1} - %m%n" />
        </layout>
    </appender>
    <appender name="rolling-file" class="org.apache.log4j.RollingFileAppender">
        <param name="file" value="${catalina.home}/logs/JMEAR.log" />
        <param name="MaxFileSize" value="10KB" />
        <!-- Keep one backup file -->
        <param name="MaxBackupIndex" value="4" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-5p %l - %m%n" />
        </layout>
    </appender>

    <logger name="org.springframework">
        <level value="warn"/>
    </logger>

    <!-- 
         everything of spring was set to "info" but for class 
         PropertyEditorRegistrySupport we want "debug" logging 
    -->
    <logger name="org.springframework.beans.PropertyEditorRegistrySupport">
        <level value="info"/>
    </logger>

    <logger name="org.springframework.flex.samples.*">
        <level value="info"/>
    </logger>
    <root>
        <priority value="info" />
        <!--<appender-ref ref="console" />
        -->
        <appender-ref ref="rolling-file" />
    </root>
</log4j:configuration>
<!--springapp-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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename">
            <value>messages</value>
        </property>
    </bean>

    <bean id="studentListController"
        class="com.oyejava.springmvc.StudentListController">
        <property name="studentDao" ref="studentDao" />
    </bean>

    <!-- command class and command name are used to retrieve and set the 
        value as name value pair in HttpRequest and Response. The form view
        tells that when the request comes for this Controller than which
        form to display in which user input can be taken. -->

    <bean id="studentCreateController"
        class="com.oyejava.springmvc.StudentCreateController">
        <property name="studentDao" ref="studentDao" />
        <property name="formView" value="createStudent" />
        <property name="commandName" value="student" />
        <property name="commandClass" value="com.oyejava.springmvc.Student" />
        <property name="validator">
            <bean class="com.oyejava.springmvc.StudentValidator" />
        </property>
    </bean>

    <bean id="loggingInterceptor"
        class="com.oyejava.springmvc.LoggingInterceptor" />

    <bean id="simpleUrlMapping"
        class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="interceptors">
            <list>
                <ref local="loggingInterceptor" />
            </list>
        </property>
        <property name="mappings">
            <props>
                <prop key="/studentList.htm">
                    studentListController
                </prop>
                <prop key="/createStudent.htm">
                    studentCreateController
                </prop>
            </props>
        </property>
    </bean>

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/jsp/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>

</beans>
<!--web.xml-->

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
    id="WebApp_ID" version="2.5">
    <display-name>SpringMVC</display-name>

    <!-- log4j configuration in web.xml -->
        <context-param>
            <param-name>log4jConfigLocation</param-name>
            <param-value>WEB-INF/log4j.xml</param-value>
        </context-param>
        <listener>
            <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
        </listener>
    <!-- /log4j configuration in web.xml END -->

    <!-- The parameter tells about the location of configuration XML. Usually
    all the data access beans and service layer beans are kept here. You can register
    more than one XML here. -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/applicationContext.xml</param-value>
    </context-param>

    <!-- The listener is reponsible for building the spring container. It looks for
        all configuration XML as defined by parameter contextConfigLocation and also looks 
        for a configuration which is named as Dispatch Servlet name. In this case it will
        be named as springapp-servlet.xml -->
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <!-- Dispatcher Servlet which traps all the request targeted for Spring MVC -->
    <servlet>
        <servlet-name>springapp</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Mapping for the request. It can be anything -->
    <servlet-mapping>
        <servlet-name>springapp</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
</web-app>
springappservlet.xml

<!--applicationContext.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!-- The Dao class -->
<bean id="studentDao" class="com.oyejava.springmvc.StudentJdbcDao">
    <property name="simpleJdbcTemplate" ref="jdbcTemplate" />
</bean>

<!-- Template class to access JDBC code -->
<bean id="jdbcTemplate"
    class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
    <constructor-arg ref="dataSource" />
</bean>

<!-- Configuration for the data source -->
<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <!-- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />-->
    <property name="url" value="jdbc:mysql://localhost:3306" />
    <!-- <property name="url" value="jdbc:hsqldb:hsql://localhost" />-->
    <property name="username" value="root" />
    <property name="password" value="" />
</bean>
</beans>
<!--log4j.xml-->

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <!-- Appenders -->
    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <param name="Threshold" value="info" />
        <param name="Target" value="System.out" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{ABSOLUTE} [%t] %-5p %c{1} - %m%n" />
        </layout>
    </appender>
    <appender name="rolling-file" class="org.apache.log4j.RollingFileAppender">
        <param name="file" value="${catalina.home}/logs/JMEAR.log" />
        <param name="MaxFileSize" value="10KB" />
        <!-- Keep one backup file -->
        <param name="MaxBackupIndex" value="4" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-5p %l - %m%n" />
        </layout>
    </appender>

    <logger name="org.springframework">
        <level value="warn"/>
    </logger>

    <!-- 
         everything of spring was set to "info" but for class 
         PropertyEditorRegistrySupport we want "debug" logging 
    -->
    <logger name="org.springframework.beans.PropertyEditorRegistrySupport">
        <level value="info"/>
    </logger>

    <logger name="org.springframework.flex.samples.*">
        <level value="info"/>
    </logger>
    <root>
        <priority value="info" />
        <!--<appender-ref ref="console" />
        -->
        <appender-ref ref="rolling-file" />
    </root>
</log4j:configuration>
<!--springapp-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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename">
            <value>messages</value>
        </property>
    </bean>

    <bean id="studentListController"
        class="com.oyejava.springmvc.StudentListController">
        <property name="studentDao" ref="studentDao" />
    </bean>

    <!-- command class and command name are used to retrieve and set the 
        value as name value pair in HttpRequest and Response. The form view
        tells that when the request comes for this Controller than which
        form to display in which user input can be taken. -->

    <bean id="studentCreateController"
        class="com.oyejava.springmvc.StudentCreateController">
        <property name="studentDao" ref="studentDao" />
        <property name="formView" value="createStudent" />
        <property name="commandName" value="student" />
        <property name="commandClass" value="com.oyejava.springmvc.Student" />
        <property name="validator">
            <bean class="com.oyejava.springmvc.StudentValidator" />
        </property>
    </bean>

    <bean id="loggingInterceptor"
        class="com.oyejava.springmvc.LoggingInterceptor" />

    <bean id="simpleUrlMapping"
        class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="interceptors">
            <list>
                <ref local="loggingInterceptor" />
            </list>
        </property>
        <property name="mappings">
            <props>
                <prop key="/studentList.htm">
                    studentListController
                </prop>
                <prop key="/createStudent.htm">
                    studentCreateController
                </prop>
            </props>
        </property>
    </bean>

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/jsp/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>

</beans>
<!--web.xml-->

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
    id="WebApp_ID" version="2.5">
    <display-name>SpringMVC</display-name>

    <!-- log4j configuration in web.xml -->
        <context-param>
            <param-name>log4jConfigLocation</param-name>
            <param-value>WEB-INF/log4j.xml</param-value>
        </context-param>
        <listener>
            <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
        </listener>
    <!-- /log4j configuration in web.xml END -->

    <!-- The parameter tells about the location of configuration XML. Usually
    all the data access beans and service layer beans are kept here. You can register
    more than one XML here. -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/applicationContext.xml</param-value>
    </context-param>

    <!-- The listener is reponsible for building the spring container. It looks for
        all configuration XML as defined by parameter contextConfigLocation and also looks 
        for a configuration which is named as Dispatch Servlet name. In this case it will
        be named as springapp-servlet.xml -->
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <!-- Dispatcher Servlet which traps all the request targeted for Spring MVC -->
    <servlet>
        <servlet-name>springapp</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Mapping for the request. It can be anything -->
    <servlet-mapping>
        <servlet-name>springapp</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
</web-app>

java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener


似乎您没有将spring-web.jar依赖项包含到类路径中(在web-INF/lib中)。

嗨,Gabriel,谢谢您的回答。我已使用新的错误消息编辑了我的初始消息。请不要在webapp类路径中包含servlet-api.jar。问题是否来自错误消息的第二行中所表达的内容?如果是,请如何修理<代码>信息:在java.library.path上找不到允许在生产环境中实现最佳性能的基于APR的Apache Tomcat本机库:/usr/lib/jvm/jdk1.7.0/jre/lib/amd64/server:/usr/lib/jvm/jre/lib/amd64:/usr/lib/jvm/jdk1.7.0/jre/。/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jre/jre/jre/jvm/jre/jvm/jvm/jvm/amd64:/usr/lib,我在路径中包含了servlet-api.jar,因为项目中有一些sevlet。关于库的包含,属性->Java构建路径->添加jar并将它们复制到WEB-INF/lib中吗?确保所需的库包含在部署程序集中(项目属性->部署程序集中),并且servlet api不存在。