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
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
解决方案 »
- MVC中的M到底是指什么???理解不透,求教!!!
- jsp页面输出下拉框乱码,邪门了!
- js变量取值问题
- Struts2标签的简单小例子,为什么总报错啊!!!!!
- Eclipse问题!!高手请进!
- 新手jsf 问题: form提交的时候如何获取 selectOneRadio 的当前值?谢谢!
- 首页中的这个bean(FeaturedItemsKey)有可能是哪里定义的呢?查遍了文件,没找到.
- 如何确定表中的记录个数?
- old problem :weblogic and servlet ,80分!谢谢!
- SSH中3张表关联,XML都配置好,从第一张表调不到第三张表的数据
- 小弟关于对 javascript中对像函的问题
- struts如何在一个页面中自动调用一个Action?
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
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