第一次提示后选择保存正常,而选择打开就会再次弹出打开另存对话框,第二次点打开就正常打开了,这是怎么回事,哪位大虾帮个忙啊!!!!
解决方案 »
- 外键问题 急,请教各位
- 使用包的servlet需要有什么特殊的配置么?
- 这个是什么错?
- 关于hibernate批量更新及删除问题
- tomcat和access做的jsp程序
- <Json>提交成功后不跳转
- 求救!!如何在jbuilder中使用jspSmartUpload,因为某些原因必须使用tomcat4.0,请问如何配置??
- 急救!!!!HELP!!!!
- 为什么在Win98下好好的,Linux上就报空指针错误啊?(附代码)
- 【求助】jsp中的include指令能不能包含xml文件?
- JSP里如何判断一个变量是否null
- 请教:使用iReport+JasperReports+struts 出现的问题
function downLoad(){
var check_num=getCheckNum(form1,"listCheck");
if (check_num==0)
{
alert("请选择需要打开或下载的传真源文件(可多选),谢谢!");
return false;
}
if(check()){
form1.cmd.value="downFile";
form1.action="/jsp/info/emailFax/FaxManageList.do";
form1.submit();
}
}java代码:
//打开下载源文件
public ActionForward downFile(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception { String[] docIds = request.getParameterValues("listCheck");
String[] filename=new String[docIds.length];
String[] rptfiletype=new String[docIds.length];
String[] Strnum=new String[docIds.length];
for (int i = 0, j = docIds.length; i < j; i++) {
Strnum=docIds[i].split(",");
filename[i]=Strnum[0];
rptfiletype[i]=Strnum[2];
}
byte[] retByte=null;
FaxManageListService serviceNew = (FaxManageListService)getService();
try {
retByte = serviceNew.downFile(filename,rptfiletype);
serviceNew.writeStreamToReponse(response,retByte,filename);
return null;
}catch(ServiceException e){
request.setAttribute("exception",e.getMessage());
}
request.setAttribute(getPageSql(),request.getParameter(getPageSql()));
referenceData(request);
return mapping.findForward("list");
}
//取出下载文件
public byte[] downFile(String[] filename,String[] rptfiletype)
{
//生成命令行
String cmdline="";
cmdline=buildcmdline(filename,rptfiletype);
//执行sh脚本到服务器上取文件
// int result;
// result = execLocal(cmdline);
// if (result!=0){
// throw Tools.createException("E007_031", ErrorConstants.E007_031,null);
// }
if (filename.length <= 1) {
// 下载一个文件
//docIds[0]=docIds[0].substring(0,docIds[0].indexOf(","));
String filePath="D:\\深圳国漫\\faxsrc\\"+filename[0];
return FileWareTools.getFileContectFromWare(filePath); } else {
// 下载多个文件
String[] filePaths = new String[filename.length];
for (int i = 0, j = filename.length; i < j; i++) {
//docIds[i]=docIds[i].substring(0,docIds[i].indexOf(","));
filePaths[i]="D:\\深圳国漫\\faxsrc\\"+filename[i];
}
return FileWareTools.createZipFile(filePaths); }
}
//输出流
public void writeStreamToReponse(HttpServletResponse response,byte[] retByte,String[] docIds) throws Exception {
response.setContentType("application/x-download");
if (docIds.length <= 1){
response.setHeader("Content-Disposition", "attachment;filename="
+ DoTextBean.gb2iso(docIds[0]));
}
else{
response.setHeader("Content-Disposition", "attachment;filename="
+ DoTextBean.gb2iso("tmp.zip"));
}
OutputStream downOut = response.getOutputStream();
downOut.write(retByte);
downOut.flush();
downOut.close();
}
//取得源文件所在路径
public String[] getfilepath(String[] rptfiletype)
{
String[] filepath=new String[rptfiletype.length];
for (int i=0,j=rptfiletype.length;i<j;i++){
String Strsql="select fax_path from rpt_file_type where rpt_file_type='"+rptfiletype[i]+"'";
ErrorVO err=new ErrorVO();
List pathlist = new ArrayList();
pathlist=QueryTools.queryToList(Strsql,getConnName(),err);
filepath[i]=(String) pathlist.get(0);
}
return filepath;
}