为什么有的JSp页面打开以后默认是简体中文(GB2312)编码的,有的是西欧(iso)编码的,西欧编码打开的就是乱码,要在浏览器上修改编码才能显示出来。
在文件里面已经加入了<% page contentType="text/html charset=GB2312 " %>
后来又在<head>标记下面加入了<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
还是不行,最不能理解的就是,有的文件打开以后默认是GB2312的,有的就默认的是西欧的 求解?

解决方案 »

  1.   

    你右键项目名称,在最下面点击properties,再弹出来的框 中,选择 resource,在右边的text file encoding 中选择你要的编码。。建议在开始一个项目的时候最好就固定编码,否则以后会时不是时的给你一点乱码。够头痛的。
      

  2.   

    这样试试<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
    你还有连接servlet了吗?如果连接了,在servlet里面有编码也要写成GB2312就是让你整个项目有关编码的地方都要写成一致的哈
      

  3.   

    大部分浏览器默认是 UTF-8的不过你先要保证你的工程和数据库的编码一致
      

  4.   

    我写jsp的时候 都是把编码改为UTF-8的、很少出现乱码
      

  5.   

    把编码改成UTF-8 应该没问题,建议你一开始做项目是把编码默认成UTF-8
      

  6.   

    你可以写一个过滤器,
    package com.filter;import java.io.IOException;import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;public class Filter implements javax.servlet.Filter { public void destroy() {
    // TODO Auto-generated method stub
         } public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain) throws IOException, ServletException {
    // TODO Auto-generated method stub
    HttpServletRequest req = (HttpServletRequest) request ;
    HttpServletResponse resp = (HttpServletResponse) response ;
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    chain.doFilter(request, response);
    } public void init(FilterConfig arg0) throws ServletException {
    // TODO Auto-generated method stub

    }}