站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题请教生成CSV文件乱码问题,大虾来看看呀

请教生成CSV文件乱码问题,大虾来看看呀

摘要: 请教生成CSV文件乱码问题,大虾来看看呀


服务器端是日文linux,客户端是日文xp,在JSP中拿到数据后out.print数据,encoding用的是ISO8859_1,但生成出来的CSV文件的日语部分都是乱码,谁知道怎么解决,谢谢!


linux下面是由这样的问题的。而且不仅仅是linux,windows下面的websphere也有同样的问题

你CSV文件的日语部分是哪部分?

是不是只要是日文就是乱码?


只要是日文的就乱码


public static final ActionForward downloadCSVFile(
HttpServletResponse response,
String outFileName,
String inFilePath)
throws IOException, ZZServerException {

response.setCharacterEncoding("Windows-31J");
response.setContentType("application/pdf");
response.setHeader(
"Content-Disposition",
"attachment; filename="
+ new String(outFileName.getBytes("Windows-31J"), "ISO8859_1"));

ServletOutputStream ouputStream = response.getOutputStream();
BufferedInputStream bis = null;
BufferedOutputStream bos = null;

try {
bis =
new BufferedInputStream(
new FileInputStream(new File(inFilePath)));
bos = new BufferedOutputStream(ouputStream);

byte[] buff = new byte[2048];
int bytesRead = 0;

while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
bos.flush();
} catch (Exception e) {
throw new ZZServerException("ZZE1999");
} finally {
if (bis != null) {
bis.close();
}
if (bos != null) {
bos.flush();
bos.close();
}
if (ouputStream != null) {
ouputStream.close();
}
}
return null;
}


ISO8859_1字符集里根本不包括日文字符,不知道你怎么输出的?

谢谢,猫猫,搞定了


↑返回目录
前一篇: Myeclips 配置问题(在线等)
后一篇: 求一段jsp写的EXCLE数据导入oracle数据库的代码.(100分求)