LZ,看到你说程序肯定没错,我就想起一个前辈给我说过的一句话:“如果结果有错,程序肯定有错!我宁愿相信电脑也不会相信人!”人毕竟有疏忽的时候,所以我觉得可能是你哪里有那么一点疏忽造成的,再内心细致的找找!当然也有可能是开发环境的一些BUG!总之我觉得结果不对了肯定有错,当然这些错误不纯粹的包括程序代码的错误,还包括开发工具,开发环境等等的错误!

解决方案 »

  1.   

    checkEncodingFilter帖出来瞧瞧,
    实在找不到问题,那就是肯定有问题。
      

  2.   

    谢谢两位手写的时候com.filter.www.checkEncodingFilter写错了,是com.filter.cf.checkEncodingFilter,跟XML设置的类对应的,checkEncodingFilter中代码是package com.filter.cf;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import java.io.IOException;
    /**
     * @author Administrator
     *
     * TODO To change the template for this generated type comment go to
     * Window - Preferences - Java - Code Style - Code Templates
     */
    public class checkEncodingFilter implements Filter{
    private FilterConfig config=null;         //定义FilterConfig对象
    private String targetEncoding="gb2312";   //定义默认编码
    public void init(FilterConfig config) throws ServletException{
    this.config=config;
    //得到XML中定义编码
    this.targetEncoding=config.getInitParameter("encoding");
    }

    public void doFilter(ServletRequest request,
    ServletResponse response,
    FilterChain chain
    ) throws IOException,ServletException{
        
        //设置编码
    request.setCharacterEncoding(targetEncoding);
    chain.doFilter(request,response);
    }

    public void destroy(){
    config=null;
    }
    }
      

  3.   

    在找问题的过程中发现难以理解的问题
    我在有标签库的登陆界面有<bean:message key="userinfo.login.title"/>这个标签,我把XML中设置过滤器的代码注释掉,程序运行正常,加上过滤器后就出现"/tags/struts-html" not found
    的错误提示了,我再把过滤器加上,程序运行正常,且过滤器正常工作,当我把我<bean:message key="userinfo.login.title"/>这个标签换一个位置时如,从<html:form>里移动到外面时,程序马上就又提示"/tags/struts-html" not found,在XML中把过滤器注释掉,标签可正常显示,程序正常显示后,把过滤器加上程序又可以正常运行,把标签的位置又放回到最原来的位置<html:form>中程序又提示"/tags/struts-html" not found不知道这是怎么回事情,实在是想不明白,我TOMCAT服务器启动时,报出很多这种提示,
    严重: Parse Error at line 27 column 65: Element type "put" must be declared.
    严重: Parse Error at line 30 column 80: Element type "definition" must be declared.
    严重: Parse Error at line 31 column 43: Element type "put" must be declared.
      

  4.   

    实在是很郁闷,当正常运行时,我把程序里<bean:message key="userinfo.login.title"/>删除掉后,刷新后马上就又出现/tags/struts-html" not found
    的错误提示了,重复上面说的把XML中filter设置注释掉再刷新,系统运行正常,再把filter加上,系统也运行正常,如果再把<bean:message key="userinfo.login.title"/>这句话加上系统又出现/tags/struts-html" not found 了,