zoukankan      html  css  js  c++  java
  • 严重: Exception starting filter struts2解决方法!

    转自:http://blog.knowsky.com/260578.htm

    问题出现:

    严重: 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目录的根目录里,否则有时不能识别。

    文章来自百度!

  • 相关阅读:
    flexible
    arcgis
    vue 语法糖
    sass 的安装 编译 使用
    nodeJs
    微信小程序
    linux cgroups 简介
    git命令
    sublime笔记
    工程优化学习(进退法、黄金分割法、二次插值法、三次插值法、最速下降法)
  • 原文地址:https://www.cnblogs.com/wangpei/p/5222599.html
Copyright © 2011-2022 走看看