我做了个网站 主页用<%@ include file="xxx.jsp"%>这样的方式 调用了 几个网页!
在主页里 设置了<%@ page contentType="text/html; charset=gb2312"%> 
其他 调用的页的字体都变成了 乱码 如果在 调用的页里加<%@ page contentType="text/html; charset=gb2312"%> 话出现冲突! 我该怎么办了?? 
请大家 帮帮忙!

解决方案 »

  1.   

    写个方法
     public String codeToString(String str)
    {
      String str1=str;
      try{
          byte b[]=new byte[1024];
         b=str1.getBytes("ISO-8859-1");
        str1=new String(b);
        return str1;
    }
    catch(Exception e)
    {return str1;
    }}
      

  2.   

    这个 方法 写在那里呢? javabean 里吗?
      

  3.   

    这个方法你想写哪就写哪啊
    你只要能调用这个函数codetoString(request.getparameter("你的内容")); 
     public String codtoString(String str)
       {
           String str1=str;
          try{
           byte b[]=new byte[1024];
           b=str1.getBytes("ISO-8859-1");
           str1=new String(b);
          }catch(Exception e)
          {
              e.printStackTrace();
        return str1;
          }
         return str1;  }
      

  4.   

    用servlet中的filter过滤器,重新设置request请求的编码。
      

  5.   

    但我没用 servlet 啊! include 的文件里 只是 html 代码!没用jsp 代码
      

  6.   

    http://www.tongfudiamond.com 就是这个网站 !
    哪个页里面都没加 <%@ page contentType="text/html; charset=gb2312"%>
    在主页里,右键->编码->简体中文(GB2312) 出现中文
      

  7.   

    最简单的办法就去网上下个过滤器加在Web.xml里面去就行了!
      

  8.   

    见个过滤器package java_0704;import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;public class SetCharacterEncodingFilter extends HttpServlet implements Filter {
      private FilterConfig filterConfig;  //Handle the passed-in FilterConfig
      public void init(FilterConfig filterConfig) throws ServletException {
        this.filterConfig = filterConfig;
      }  //Process the request/response pair
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
          throws IOException,ServletException {
        request.setCharacterEncoding("GB2312");
        filterChain.doFilter(request,response);
      }  //Clean up resources
      public void destroy() {
      }
    }
      

  9.   

    odyseey()==> 生成.class 文件以后 怎么到入.jsp文件里呢? 用什么方法