<%@ page import="java.io.*"%>
<%@ page language="java" pageEncoding="GB2312"%>
<%
Object oReport = session.getAttribute("strPrint");
String strReport = null;
if (oReport != null) {
strReport = oReport.toString();
}
System.out.println(strReport);
//strReport为中文
String filename = "report.txt";
StringBuffer contentDisposition = new StringBuffer();
contentDisposition.append("attachment;");
contentDisposition.append("filename=\"");
contentDisposition.append(filename);
contentDisposition.append("\""); response.setHeader("Content-Disposition", contentDisposition
.toString()); byte byteBuf[] = new byte[100000];
try {
byteBuf = strReport.getBytes("ISO-8859-1");
out.clearBuffer();
out.write(byteBuf);
} catch (IOException ex) {
ex.printStackTrace();
}
%>
下载的txt为
2007-09-19to2007-09-19
???????:
?? DCH-3000ECMUX ?????21 ? ,
<%@ page language="java" pageEncoding="GB2312"%>
<%
Object oReport = session.getAttribute("strPrint");
String strReport = null;
if (oReport != null) {
strReport = oReport.toString();
}
System.out.println(strReport);
//strReport为中文
String filename = "report.txt";
StringBuffer contentDisposition = new StringBuffer();
contentDisposition.append("attachment;");
contentDisposition.append("filename=\"");
contentDisposition.append(filename);
contentDisposition.append("\""); response.setHeader("Content-Disposition", contentDisposition
.toString()); byte byteBuf[] = new byte[100000];
try {
byteBuf = strReport.getBytes("ISO-8859-1");
out.clearBuffer();
out.write(byteBuf);
} catch (IOException ex) {
ex.printStackTrace();
}
%>
下载的txt为
2007-09-19to2007-09-19
???????:
?? DCH-3000ECMUX ?????21 ? ,
解决方案 »
- hibernate 注册1对1关系 大家帮我看看那里错了
- jsp如何将textarea里面的内容以Word的形式保存起来
- jsf导出word
- Struts分页问题 急。。。
- 如何根据java中的变量更改html标签的属性?在线等
- webShpere4.0 + struts1.1 如何配置初学STRUTS请高手帮忙?
- 求动态生成目录树?
- 关于jsp与sql server数据库
- 如何将tomcat做为windows的一项服务启动?
- 急!在多行文本框里调用word的内容。谢!
- Hibernate代码生成工具 设计全攻略(转)
- 急。。。能用JasperReport生成html页面,但是不知道如何进行分页,请知道的话帮帮忙!
上面这句编码转变成了8859-1了
utf-8
编码 我一直用