当前位置: 代码迷 >> J2EE >> Exception starting filter encodingFilter这个异常怎样解决啊
  详细解决方案

Exception starting filter encodingFilter这个异常怎样解决啊

热度:304   发布时间:2016-04-22 02:32:20.0
Exception starting filter encodingFilter这个错误怎样解决啊?
严重: Exception starting filter encodingFilter
java.lang.ClassCastException: cn.com.csuinfo.filter.EncodingFilter
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:255)
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(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:413)
2009-5-19 13:31:15 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2009-5-19 13:31:15 org.apache.catalina.core.StandardContext start
严重: Context [/classmates] startup failed due to previous errors
2009-5-19 13:31:15 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8081
2009-5-19 13:31:16 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2009-5-19 13:31:16 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/31 config=null
2009-5-19 13:31:16 org.apache.catalina.startup.Catalina start
信息: Server startup in 1266 ms


我想问一下怎样解决这个问题啊。。。。。
这是我的EncodingFilter类:
public class EncodingFilter {
public void destroy() {
// TODO Auto-generated method stub
System.out.println("destory");
}
/**
* 对请求进行编码
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest=(HttpServletRequest)request;
httpRequest.setCharacterEncoding("UTF-8");
//HttpServletResponse httpresponse=(HttpServletResponse)response;
//httpresponse.setCharacterEncoding("GB2312");
//将请求继续丢给下面的过滤器或者是servlet做请求处理
System.out.println("doFilter");
chain.doFilter(request, response);

}

public void init(FilterConfig arg0) throws ServletException {
System.out.println("init");
}

}
下面是我的xml中关于filter的一段文档:
<filter>
<filter-name>encodingFilter</filter-name>
  相关解决方案