怎么用把读取后的文件直接写入页面,能正常显示中文

解决方案 »

  1.   

    转码示例:byte[] b = str.getBytes("ISO8859_1");
    str = new String(b, "gb2312");
      

  2.   

    <%@page contentType="text/html;charset=GBK" %>
    这个要在第一行
    然后后面才是你的读文件的代码
    另,把你读文件的代码发上来,我怀疑你写的有问题!
      

  3.   

    最好还是过滤一下,用下面的方法过滤你的string
    <%!
    //处理中文问题的自定义函数
    public String getStr(String str)
    {
      try
      {
        String temp_p=str;
        byte[] temp_t=temp_p.getBytes("ISO8859-1");
        String temp=new String(temp_t);
        return temp;
      }
      catch(Exception e)
      {
        e.printStackTrace();
      }
      return "null";
    }
    %>