打开http://localhost:8080/test.jsp
页面没有乱码。
里面的表单提交给struts action,得到的表单数据不是乱码,action再转到test.jsp时。页面就变成问号了。这是什么问题啊?

解决方案 »

  1.   

    过滤器public class EncodingFilter implements Filter
    {    public EncodingFilter()
        {
            pageEncoding = "gb2312";
        }    public void setFilterConfig(FilterConfig filterConfig)
        {
            this.filterConfig = filterConfig;
        }    public void init(FilterConfig config)
            throws ServletException
        {
            filterConfig = config;
            pageEncoding = config.getInitParameter("encoding");
        }    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException
        {
            HttpServletRequest hrequest = (HttpServletRequest)request;
            hrequest.setCharacterEncoding(pageEncoding);
            chain.doFilter(request, response);
        }    public void destroy()
        {
            filterConfig = null;
        }
      

  2.   

    action转到jsp是乱码,其他的都是好的
      

  3.   

    那response设置了吗?
    response.setCharacterEncoding(pageEncoding);
      

  4.   

    在fombean里做
    String words=new String(aa.getBytes("ISO8859-1"),"gb2312")