工作空间,工程,我都改成gbk了,可页面仍然是乱码,发现每个页面的编码都是iso-8859-1,修改成gbk后就行了。
可是有那么多的jsp页面,难道要一个一个的修改,有解决办法吗???

解决方案 »

  1.   

    中文乱码问题:应该说所有的情况都碰到了吧,解决也是曲折的,经过摸索,总结如下: 1、所有页面都用UTF-8。 
    2、写过滤器,设置request.setCharacterEncoding("UTF-8")。 
    3、javascript脚本里用encodeURI(str)。 
    4、适当的时候,在jsp里用java.net.URLDecoder.decode(request.getParameter("str"),"UTF-8")。 
    5、最容易忽略的是使用"":value=" <%=paraFiles%>",一定要有引号。 
    6、new String(content.getBytes("ISO-8859-1"), "GBK");
      

  2.   

    一个一个修改是最稳妥的啊,毕竟你都试过了嘛.
    如果感觉一个一个改jsp太慢了,
    那可以....两个两个的修改\( ̄▽ ̄)/
      

  3.   

    看这样可不可以:
    右键你的工程名-->Properties-->Info-->Text file encoding-->other-->选择gbk。
      

  4.   

    在web.xml配置文件中<web-app>里用
    <filter>
    <filter-name>SetCharacterEncoding</filter-name>
    <filter-class>tools.CharsetFilter</filter-class>
    <init-param>
    <param-name>Encoding</param-name>
    <param-value>GBK</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>SetCharacterEncoding</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping> 
      

  5.   

    package tools;import java.io.IOException;
    import javax.servlet.*;public class CharsetFilter implements Filter {    
        protected String encoding = null;
        protected FilterConfig filterConfig = null;
        
        protected String getEncoding() {
            return (this.encoding); 
        }
        
        public void destroy() {
            this.encoding = null;
            this.filterConfig = null;
        }    public void doFilter(ServletRequest request, ServletResponse response,
                             FilterChain chain) throws IOException,
            ServletException {        if (request.getCharacterEncoding() == null) {
                String encoding = getEncoding(); //得到指定的编码名字
                if (encoding != null)
                    request.setCharacterEncoding(encoding); //设置request的编码
            }        chain.doFilter(request, response); //有机会执行下一个filter
        }    public void init(FilterConfig filterConfig) throws ServletException {        this.filterConfig = filterConfig;
            this.encoding = filterConfig.getInitParameter("Encoding"); 
        }
    }
      

  6.   

    new String(content.getBytes("ISO-8859-1"), "GBK");或者 来个Filter吧