public String excel() throws Exception{
initRequest();
//查询ID
String queryId = request.getParameter("queryId");
RequestParamters requestParamters = new RequestParamters(request, false);
HSSFWorkbook wb = null;
try {
wb = publicSrv.excel(queryId, getSqlColumns(queryId), requestParamters);
} catch (Exception ex) {
ex.printStackTrace();
}
HttpServletResponse response = getResponse();
OutputStream os = null;
try {
QueryConfig queryConfig = ConfigQuery.getQueryConfig(queryId);
String title = null;
if(null != queryConfig){
title = queryConfig.getExcelTitle();
}
if(StrUtils.isEmpty(title)){
title = "无标题";
}
os = response.getOutputStream();// 取得输出流
response.reset();// 清空输出流
response.setHeader("Content-disposition","attachment;filename="+new String((title).getBytes(),"ISO8859_1")+".xls");// 设定输出文件头
response.setContentType("application/msexcel");// 定义输出类型
wb.write(os);
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
os.flush();
os.close();
} catch (IOException e) {}
}
return null;
}
如果action的返回写成
return SUCCESS;
在tomcat6.0.14的版本会出现
getOutputStream() has already been called for this response
,在tomcat6.0.28中没有,解决办法是action最后必须是
return null;
分享到:
相关推荐
stuts2 jar包 全部,都是可以用的jar包,欢迎大家下载 stuts2 jar包 全部,都是可以用的jar包,欢迎大家下载 stuts2 jar包 全部,都是可以用的jar包,欢迎大家下载 stuts2 jar包 全部,都是可以用的jar包,欢迎大家...
stuts2文件上传下载详解,可实现文件批量上传
Stuts入门 Stuts入门 Stuts入门 Stuts入门 Stuts入门 Stuts入门
stuts2增删改查再送登录,由stuts2加HIBERNATE+SPING为核心写的代码,数据库为MYSQL,只要大家把数据脚本导入进去就OK。帮助大家提升编写能力。
struts2+ajax框架结合,异步传送数据....
spring 和stuts2整合spring 和stuts2整合spring 和stuts2整合spring 和stuts2整合spring 和stuts2整合
stuts2搭建环境步骤
struts2开发用到的一些jar包stuts2.jar
包括了struts2 Spring所用的jar包,以及struts2跟Spring的配置文件实例
stuts2和extjs结合实例比较通俗易懂
简单的Stuts2项目,功能很好。虽然简单。但是有很多好的功能
stuts2权威指南第4章第4.2节part2.....
eclipse-help-...不会的加我qq:287839128
Stuts+Spring(郭克华)方法二,此范例是郭老师源码(一共有三种方法),希望郭老师粘合的框架能给你带来帮助,能让你尽快了解ssh粘合的过程!!!!
stuts2文件上传,带进度条!
stuts翻译教材stuts翻译教材stuts翻译教材stuts翻译教材stuts翻译教材
尚硅谷stuts2练习中的自定义类型转换器练习
spring、mybatis、stuts2整合、注解方式
这是初学者可以学习的strut2文档,里面详细介绍struts2的具体内容,欢迎各位下载!
Stuts2+hibernate3.0+Spring3.0整合