<%
String errString = new String(request.getAttribute("error").getBytes("ISO8859_1"));
%>
<%=errString%>

解决方案 »

  1.   

    你的文件要用word或者相应的软件,使得保存的数据就是繁体的,否则你使用的是简体的字体保存,用繁体来显示,那不是乱码才怪。
      

  2.   

    试试:
    package tools;public class ts{
    public static String gbTo(String gbStr)
    {
    String str = null;
    try{
    str    = new String(gbStr.getBytes("big5"),"8859_1");
    }catch(Exception e){}
    return       str;
    }
    public static String toGb(String Str)
    {
    String str = null;
    try{
    str    = new String(Str.getBytes("8859_1"),"big5");
    }catch(Exception e){}
    return       str;
    }
    }
      

  3.   

    1.req.setAttribute("error",new String("繁体中文字".getBytes("big5"),"iso8859_1"));
    2.<%@ page language="java" contentType="text/html;charset=big5" %>
    3.<meta http-equiv="Content-Type" content="text/html; charset=big5">
      

  4.   

    如果还不行,将req.setAttribute("error",new String("繁体中文字".getBytes("big5"),"iso8859_1"));中的字符集名称掉换一下再试试。
      

  5.   

    我是用tomcat4.0来做的处理繁体字时,一定要将编码设为contentType="text/html; charset=BIG5"
    如果没有这样指定,可以这样来reponse.setContentType("text/html; charset=BIG5")
    假若你从上一个页面传入一个参数txt,txt的值为'發',那么你取它的值时应该这样写
    <%
      String str=new String(request.getParameter("txt").getBytes("ISO8859_1"),"GBK");
    %>
    注意不是
    <%
      String str=new String(request.getParameter("txt").getBytes("ISO8859_1"),"BIG5");
    %>
    所以你如果要输出时只用这样<%out.println(str);%>
    若存入到数据库中insert into table values(str);
    从数据库中取出时,也不用在对str转码。rs.getString("str");就可以了!
    -----------------------------
    这样做的有很明显的局限性:
    因为,gb2312和big5并不能共存了,也就是说,你的页面要么全是繁体,要么全是简体,正常的情况下,这当然是可以了,因为没有哪个页面一会用简体,一会用繁体,但我想毕竟还是有的页面是有这种情况的。
    而且现在有的字符处理程序用的是什么码表来解决的,估计能解决上面的问题吧,正在研究中!^-^