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

为什么tomcat不能加载web.xml中的过滤器????
为什么我在web.xml文件中,加入以下代码就不能正常启动tomcat
<filter>
  <filter-name>PagerFilter</filter-name>
  <filter-class>com.bjsxt.oa.web.PagerFilter</filter-class>
  </filter>
 <filter-mapping>
  <filter-name>PagerFilter</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>

 项目中有PagerFilter 这个类。

出现的提示错误是:

008-11-29 23:06:59 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter PagerFilter
java.lang.ClassNotFoundException: com.bjsxt.oa.web.PagerFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:249)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3693)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1023)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1015)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2008-11-29 23:06:59 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2008-11-29 23:06:59 org.apache.catalina.core.StandardContext start
严重: Context [/oa_1] startup failed due to previous errors
2008-11-29 23:06:59 org.apache.catalina.core.ApplicationContext log

------解决方案--------------------
PagerFilter 类没有继承Filter类?
------解决方案--------------------
明显是找不到那个类
1、检查看你那个com.bjsxt.oa.web.PagerFilter是准确无误的
2、好像你喜欢中间那里留有空格,可能会有问题吧,把所有的空格去了看
<filter-name>PagerFilter </filter-name> 
<filter-class>com.bjsxt.oa.web.PagerFilter </filter-class> 
<filter-name>PagerFilter </filter-name>
<url-pattern>/* </url-pattern>
------解决方案--------------------