我的jsp页面有一个按钮,单击进入action查询数据然后导出excel,再跳转到但前页面显示查询出来的数据,
执行时报错:getOutputStream() has already been called for this response,在网上看的在页面写out.clear();
out = pageContext.pushBody();
,但没有用,请问我该怎么解决,谢谢!!!
执行时报错:getOutputStream() has already been called for this response,在网上看的在页面写out.clear();
out = pageContext.pushBody();
,但没有用,请问我该怎么解决,谢谢!!!
解决方案 »
- 请教一个Quartz表达式?
- Struts2.1.6+spring2.5.6+hibernate3.3.1框架集报错:Context initialization failed
- 麻烦大家,帮忙:)
- wsdl文件拿来生成java类,在通过类来发布服务!!高手进进
- onsubmit()方法为什么return
- 哪位大哥能帮我做个题目啊。。急!!!
- jsp 数据库访问问题
- 请教诸位大侠一个有关xml的问题,老美限我二十四小时内解决,请大伙多多帮忙提供一个思路啦
- 谁能给我讲讲分页的东西!Struts里的
- java rmi代码如何设计好?有高分酬谢!
- 想用spring+hibernate实现自动生成表和pojo的方法
- 有对activemq研究的吗?
楼主【Arthur3726】截止到2008-07-24 10:02:01的历史汇总数据(不包括此帖):
发帖的总数量:15 发帖的总分数:300 每贴平均分数:20
回帖的总数量:6 得分贴总数量:1 回帖的得分率:16%
结贴的总数量:6 结贴的总分数:120
无满意结贴数:0 无满意结贴分:0
未结的帖子数:9 未结的总分数:180
结贴的百分比:40.00 % 结分的百分比:40.00 %
无满意结贴率:0.00 % 无满意结分率:0.00 %
楼主该结一些帖子了
/*************导出excel***************/
if(outTag != null && "outYes".equals(outTag))//outTag==“outYes”则导出excel
{
String fName = "企业信息";
if(action!=null && action.equals("cp"))
{
fName = "产品信息";
}
OutputStream os = response.getOutputStream();//取得输出流
response.reset();//清空输出流
response.setCharacterEncoding("UTF-8");
fName = URLEncoder.encode(fName,"UTF-8");
response.setHeader("Content-Disposition", "attachment; filename="+ new String(fName.getBytes("UTF-8"), "GBK") + ".xls");//扩展名为:.xls
response.setContentType("application/vnd.ms-excel");//定义输出类型excel:vnd.ms-excel,pdf:pdf
InputStream is = null;
File fileExcel = new File("D:/excel/mywritefile2.xls");//本地绝对路径
try {
if(fileExcel != null && !"".equals(fileExcel))
{
is = new FileInputStream(fileExcel);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] buff = new byte[1024];//定义缓冲区
int len;
try {
while((len = is.read(buff)) != -1) {//文件没到头
os.write(buff, 0, len);
}
is.close();//关闭输入输出流
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/*************************************************/
request.setAttribute("pageNo",pageNo);
request.setAttribute("action",action);
request.setAttribute("city",city );
request.setAttribute("type", type);
request.setAttribute("zhuangtai", zhuangtai);
request.setAttribute("datetime", datetime);
request.setAttribute("gjz", gjz);
return new ActionForward("forward","/count/find/findshujujiansuo.jsp",false);