1、本地tomcat,服务器resin
2、使用的数据文件一样字符为GB2312(在服务器端转换过的)
3、测试时只是路径变化了,其他都没有变化结果:
本地测试时文件内容显示正常
服务器测试时。文件内容乱码源程序部分代码:
<%@ page import="java.io.*" buffer="32kb"%>
<%@ page contentType="text/html; charset=GB2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body>
<BR><BR><BR><BR>
<H2 align='center'>Report Download</H2>
<p align='center'><BR>=====================================================================<BR>
<table >
<Title>Report Download</Title>
<%
try
{  
    String str="";
    String strURL="";
    String content="" ;
    String FilePath="/home/report/" ;
    //String FilePath="c:\\" ;
//打开文件输入流,将文件中数据读取到缓冲区
    //BufferedReader br=new BufferedReader(new FileReader(FilePath+"FileList.lst"));
    BufferedReader br=new BufferedReader(new FileReader(FilePath+"FileList.lst"));    while((content=br.readLine())!=null)
    {
    //out.println(content) ;
    //str = new String(content.getBytes(),"GB2312") ;
    strURL = FilePath + content ;
    //out.println(strURL) ;
%>
<a href="<%=strURL%>"><%=content%></a><br>
<%
    }     
     br.close();
}
catch(Exception ex)
{
  out.println(ex);
}
%>服务器结果:
A00001.??????????????.2007??1??29??.csv
A00001.Exposure.2007??1??29??.csv本地结果:
A00001.蒙特卡罗历史报表.2007年1月29日.csv
A00001.Exposure.2007年1月29日.csv

解决方案 »

  1.   

    看下浏览器的Encoding是不是被设置成非常用编码啦?
      

  2.   

    Glen Ning:unix/linux服务器上默认的编码为utf-8,因此将csv文件用editplus打开用utf-8格式另存为csv文件再上传!
      

  3.   

    另外一种方法,请看InputStreamReader的jdk doc:
    InputStreamReader
    public InputStreamReader(InputStream in,
                             String charsetName)
                      throws UnsupportedEncodingException
    Create an InputStreamReader that uses the named charset. Parameters:
    in - An InputStream
    charsetName - The name of a supported charset 
    Throws: 
    UnsupportedEncodingException - If the named charset is not supported
      

  4.   

    FYI:
    US-ASCII     Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set 
    ISO-8859-1   ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1 
    UTF-8        Eight-bit UCS Transformation Format 
    UTF-16BE     Sixteen-bit UCS Transformation Format, big-endian byte order 
    UTF-16LE     Sixteen-bit UCS Transformation Format, little-endian byte order 
    UTF-16       Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order