严重: Exception starting filter struts2解决方法!

问题出现:

严重: Exception starting filter struts2
java.lang.ClassNotFoundException: prg.apache.struts2.dispatcher.FilterDispatcher
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1666)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:406)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:388)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:117)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:248)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:368)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4193)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4801)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:771)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:427)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:649)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
2010-12-1 13:10:06 org.apache.catalina.core.StandardContext startInternal
严重: Error filterStart
2010-12-1 13:10:06 org.apache.catalina.core.StandardContext startInternal
严重: Context [/struts2] startup failed due to previous errors

?

解决方法:

很明显的错误:java.lang.ClassNotFoundException: FilterDispatcher
找不到FilterDispatcher这个类(FilterDispatcher分发器,是Struts2框架的核心Dispatcher,没有它,也就谈不起Struts2框架
首先:看看有没有导入Struts2相应的jar包,是否齐全。最少要导入五个基本包:
commons-logging-api-1.1.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
struts2-core-2.0.12.jar
xwork-2.0.6.jar

如果该包含的jar包都引入了,再看,配置文件web.xml是否配置正确,
struts2使用的是Filter充当Control? 需要配置web.xml如下:注意类名和包名不要写错
<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>*.do</url-pattern>
  <!--? 这里的url-pattern视你的具体情况而定-->
</filter-mapping>
<filter-mapping>
 <filter-name>struts2</filter-name>
  <url-pattern>/struts/*</url-pattern>
</filter-mapping>
如果以上两步都没有问题,那估计就是环境问题了,在开发中,环境问题是麻烦的事,检查你用的部署服务器(Tomcat或weblogic等)、IDE的版本(eclipse或者myEclipse),以及Struts2的版本...
struts2项目中web.xml配置2.1与2.0的区别
具体的过滤器类变了,2.0配置是以上写法
2.1以后是这样配置
<filter>
  <filter-name>struts2</filter-name>
  <filter-class>
  org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
 </filter-class>
</filter>
<filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
另外,也与你导入jar包的位置有关,建议最好放入工程WEB-INF下的lib目录里,有时不能识别。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值