日期:2014-05-20  浏览次数:20723 次

最简单的struts2 实验 出错了,求指点
我用的struts2 2.2.3

commons-fileupload-1.2.2
commons-io-2.0.1
commons-lang-2.5
commons-logging-1.1.1
freemarker-2.3.16
javassist-3.11.0.GA
ognl-3.0.1
struts2-core-2.2.3
xwork-core-2.2.3
这几个包都导入了

但启动tomcat的时候会报 严重: Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:252)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4461)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5133)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5128)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)

照提示是说找不到那个类,但我绝对导进去了,就是这个包struts2-core-2.2.3
 我把我的XML配置文件也放出来一下

web.xml
Java code
<?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">
<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>


struts.xml

Java code
 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
      "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
      "http://struts.apache.org/dtds/struts-2.0.dtd">
  <struts>
         <package name="struts" extends="struts-default">
          <action name="login" class="action.LoginAction">
           <result name="error">/error.jsp</result>
            <result name="success">/welcome.jsp</result>
        </action>
      </package>
  </struts>


------解决方案--------------------
Struts2.2.3好像不是这么配的。

你把你下载到的Struts的那个压缩包里面的例子的web.xml打开来看一下,他的例子是怎么配置的,你按照那个改过去就行了。我记得不是这个FilterDispatcher
------解决方案--------------------
探讨

我来告诉你,你这个版本的要这么配,一般都是导入包不全
<filter>