liliangjin_2008
liliangjin_2008
2010-12-02 10:07
浏览 577
已采纳

严重: Exception starting filter characterEncoding

web.xml
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
ch12

front/index.jsp

Struts info

struts2
org.apache.struts2.dispatcher.FilterDispatcher


struts2
/*


struts-cleanup
org.apache.struts2.dispatcher.ActionContextCleanUp


struts-cleanup
/*

2010-12-2 10:13:23 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter characterEncoding
java.lang.ClassNotFoundException: com.casa2.struts.characterEncodingFilter
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.(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:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2010-12-2 10:13:23 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2010-12-2 10:13:23 org.apache.catalina.core.StandardContext start
严重: Context [/ch13] startup failed due to previous errors

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • andy_javahome
    andy_javahome 2010-12-02 23:26
    已采纳

    这是我的一个项目的配置

    Set Character Encoding
    com.****.EncodingFilter

    encoding
    UTF-8



    Set Character Encoding
    /*

    EncodingFilter 的内容是

    public class EncodingFilter implements Filter {

    private FilterConfig filterConfig = null;
    private String encoding = null;
    private boolean ignore = true;
    
    public final void init(final FilterConfig arg0) throws ServletException {
        this.filterConfig = arg0;
        this.encoding = filterConfig.getInitParameter("encoding");
        String value = filterConfig.getInitParameter("ignore");
        if (value == null) {
            this.ignore = true;
        } else if (value.equalsIgnoreCase("true")) {
            this.ignore = true;
        } else if (value.equalsIgnoreCase("yes")) {
            this.ignore = true;
        } else {
            this.ignore = false;
        }
    }
    
    public final void doFilter(final ServletRequest request,
            final ServletResponse response, final FilterChain chain)
            throws IOException, ServletException {
        if (ignore || (request.getCharacterEncoding() == null)) {
            String encoding1 = selectEncoding(request);
            if (encoding1 != null) {
                request.setCharacterEncoding(encoding1);
            }
        }
        try {
            chain.doFilter(request, response);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
        //如果你没用hibernate 把这部分删除就行了      HibernateSessionFactory.closeSession();
            } catch (Exception e) {
            }
        }
    }
    
    public final void destroy() {
        this.encoding = null;
        this.filterConfig = null;
    
    }
    
    protected final String selectEncoding(final ServletRequest request) {
        return (this.encoding);
    }
    

    }
    都晚上了还没弄好啊,估计急坏了吧 :wink:

    点赞 评论
  • andy_javahome
    andy_javahome 2010-12-02 10:32

    意思是没有找到这个com.casa2.struts.characterEncodingFilter
    类。
    看你代码是不是报错了,如果没有是不是该在web.xml中加

    Set Character Encoding
    com.casa2.struts.characterEncodingFilter


    encoding
    UTF-8



    Set Character Encoding
    /*

    点赞 评论
  • andy_javahome
    andy_javahome 2010-12-02 15:54

    你不会直接把我给你这段代码拷过去了吧?

    encoding
    UTF-8

    这个地方的encoding应该是你characterEncodingFilter 类里取的,我的是用filterConfig.getInitParameter("encoding");你也可以直接写死

    点赞 评论

相关推荐