1

实际上,我正在尝试使用 Spring3 和 Hibernate4 来实现 Struts2。当我启动 Apache Tomcat 服务器并运行该index.jsp文件时,它给了我以下错误。

SEVERE: Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:527)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:509)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:137)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Aug 05, 2013 9:24:48 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Aug 05, 2013 9:24:48 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/hibernate_strut_spring] startup failed due to previous errors
Aug 05, 2013 9:24:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Aug 05, 2013 9:24:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Aug 05, 2013 9:24:48 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 425 ms

请帮助我。我是这个主题的初学者。请帮助我的朋友。

在我在 WEB-INF/lib 中添加了所有相关的 jar 文件后,它显示了一些其他错误,如下所示

SEVERE: Exception starting filter struts2
java.lang.NoSuchMethodError: com.opensymphony.xwork2.config.ConfigurationManager.addConfigurationProvider(Lcom/opensymphony/xwork2/config/ConfigurationProvider;)V
    at org.apache.struts2.dispatcher.Dispatcher.init_DefaultProperties(Dispatcher.java:310)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:411)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Aug 05, 2013 9:46:10 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Aug 05, 2013 9:46:10 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/hibernate_strut_spring] startup failed due to previous errors
Aug 05, 2013 9:46:10 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Aug 05, 2013 9:46:10 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Aug 05, 2013 9:46:10 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2836 ms

web.xml 文件

<?xml version="1.0" encoding="UTF-8"?>

<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>hibernate_strut_spring</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <filter>
        <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>
4

3 回答 3

1

在您的项目中使用相同版本的 struts jar。我想你用过不同的版本,你也错过了一些罐子。

于 2013-09-27T15:30:02.653 回答
0

struts jarstruts2-core-XXXX.jar表示XXXX版本需要找到进入应用程序类路径的方式。

这可以通过将其包含在WEB-INF/lib

于 2013-08-05T16:13:14.203 回答
0

如果您使用的是 Eclipse,请CTRL + SHIFT +T输入 FilterDispatcher 并查看是否可以struts2-core-requiredVersion.jar在窗口中找到。很可能你不会知道为什么你会收到错误。你需要在下面添加这个 jar ProjectDirectory/WEB-INF/lib

如果您使用的是 maven,请添加以下依赖项

 <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts2-core</artifactId>
      <version>latestVersion</version>
    </dependency>
于 2013-08-05T16:16:12.877 回答