下载的时候,别用这种方式,我用的from表单,提交的,但是如果你下载,包括下载报表之类的,下不了,这是异步传输的
新手求教!!关于使用struts 下载csv文件的问题 急
我配置好struts后,点击下载的时候页面没有任何的响应,这是为什么啊?
struts.xml
<action name="xxDownload" class="com.xx.action.xxAction"
method="download" >
<result name="success" type="stream">
<param name="contentType" >application/csv</param >
<param name="inputName" >stream</param>
<param name="contentDisposition" >
attachment;filename="${fileName}"
</param>
<param name="bufferSize" >4096</param>
</result>
xxAction
private InputStream stream;
String fileName;
public String download(){
try {
xx= service.search(condition);
fileName = "xx_"+Math.random()+".csv";
File file = new File(fileName);
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
String str = ".........shenglve\n";
out.write(str.getBytes());
out.flush();
for (int i = 0; i < x.size(); i++) {
str = xx.get(i).getStoreCD() + ","
+ xx.get(i).getProductCD() + ","
+ xx.get(i).getStartDate() + ","
+ xx.get(i).getEndDate() + ","
+ xx.get(i).getMassExposure() + ",aa\n";
out.write(str.getBytes());
out.flush();
}
out.flush();
stream = new FileInputStream(file);
} catch (Exception e) {
logger.error(e.getMessage(),e);
exFlag = "1";
}
return "success";
}
js
var msg ="是否下载?";
if(window.confirm(msg)){
var url = "xxDownload";
var param = {
"xx.a":"1"
,"xx.b":"2"
,"xx.c":"3"
,"xx.d":""
};
$.post(url,param);
}
- 点赞
- 写回答
- 关注问题
- 收藏
- 复制链接分享
- 邀请回答
2条回答
为你推荐
- 这个代码无法输出是哪里有问题?求教!
- 有问必答
- c++
- 2个回答
- 新手小白!如何判断用户输入的数据是否为long类型,求教!
- java
- 7个回答
- php+vue关于登录验证的问题求教!
- ajax
- php
- vue.js
- 8个回答
- 又是一个有关猫的问题,小白求教!
- java
- java-ee
- 1个回答
- 新手求教#if !defined宏标识符的问题
- 开发语言
- c++
- 1个回答
- 新手求教!!为什么ins函数里所有scanf都被跳过啊?
- c语言
- 1个回答
- 求教!安卓新闻app的服务器问题!
- app服务器
- android
- 2个回答
- java连接到mysql数据库问题,求教!
- java
- 数据库
- mysql
- 6个回答
- mysql语法问题,求教!
- mysql
- 3个回答
- 新手求教!c语言程序执行问题,,
- 求教
- 程序执行
- 新手
- c
- 8个回答
- 百度说我主键冲突,我觉得百度坏了,新手求教于!
- 新手求指导!
- 1个回答
- 关于递归求解问题求教.寻找递归大神!
- ios
- 递归
- string
- pd
- namespace
- 3个回答
- 求教大神关于gruntjs的问题!
- 1个回答
- ByteArrayOutputStream输出乱码问题,新人不懂啊,求教!
- io输出流
- 乱码。
- 2个回答
- js简单的for语句,急,新手求教!
- web
- javascript
- 11个回答
- C#集合问题,新手求教!
- c#
- class
- 4个回答
- 新手求教,关于java压缩文件的问题
- 压缩
- java
- 2个回答
- 新手求教ndlc问题!!!!
- 新手
- ndlc
- 3个回答
- 新手不知道怎么用下载下来的源代码.求教!!!
- 源代码
- 2个回答
- 新手求教mfc的问题了!
- mfc
- mfc求助
- 3个回答