我用extjs+struts1.2做文件上传时,当文件上传成功后,却弹出了下载框,而Ext里提交后的回调函数却不能响应,为什么呢? 我使用了oreilly的COS上传组件。
前台代码是:
var upwin = new Ext.Window({ //一个窗口
width:350,
title: 'Excel文件上传',
height:180,
closeAction:'close', //关闭图标 hide / close
plain: true,
modal:true,
autoScroll:true, //自动滚动
containerScroll: false,
layout: 'fit',
items:[
new Ext.form.FormPanel({
labelAlign: 'right',
labelWidth: 60,
frame:true,
url: 'pushMgrAction.do?method=uploadFile',//fileUploadServlet
width: 300,
height:200,
fileUpload: true,
items: [{
xtype: 'textfield',
fieldLabel: '文件名',
name: 'file',
width: '250',
inputType: 'file'//文件类型
}]
})
],
buttonAlign : 'center',
buttons: [{
text: '导 入',
handler: function() {
upform.getForm().submit({
success: function(form, action){
Ext.Msg.alert('信息', action.result.msg);
},
failure: function(){ Ext.Msg.alert('错误', '文件导入失败');},
waitMsg : '正在导入数据,请等待...'
});
}
},{ text: '关 闭',handler: function(){ upwin.close(); }
}]
});
upwin.show();
}
var upform = ;
action中的代码是:
response.setContentType("text/json; charset=gb2312");
MultipartRequest multi = new MultipartRequest(request, saveDirectory, maxPostSize, "gb2312");
XlsImport xlssave = new XlsImport();
//输出反馈信息
Enumeration files = multi.getFileNames();
while (files.hasMoreElements()) {
String name = (String)files.nextElement();
File f = multi.getFile(name);
if(f!=null){
String fileName = multi.getFilesystemName(name);
String lastFileName= saveDirectory+"\\" + fileName;
java.io.File tmpfile = new java.io.File(lastFileName);
if (tmpfile.exists()) {
xlssave.xlsToDB(user.getEmpid(), lastFileName);
if(xlssave.getErrors().equals("")){
redata = "{success:true,msg:'成功导入了"+xlssave.getRowCount()+"条数据!'}" ;
}else{
redata = "{success:false,msg:'"+xlssave.getErrors().toString()+"'}";
}
}
tmpfile.delete();
}
}
out.write(redata);
out.flush();
--------------------------------------------------------------------------------
分享到:
相关推荐
标题 "http://topkinghat.iteye.com/blog/840706" 提到的博客链接实际上指向了“姜铁”的个人博客文章,而描述中的 "NULL" 暂无具体信息。不过,标签“源码”和“工具”暗示了这篇博客可能涉及到软件开发的源代码...
博文链接:https://wdfan.iteye.com/blog/197543
博文链接:https://balaschen.iteye.com/blog/82579
博文链接:https://jackzhangyunjie.iteye.com/blog/202349
NULL 博文链接:https://sd5816690.iteye.com/blog/940142
NULL 博文链接:https://ownraul.iteye.com/blog/1277047
NULL 博文链接:https://timewalker.iteye.com/blog/1065615
NULL 博文链接:https://wincheer.iteye.com/blog/774298
NULL 博文链接:https://qiusenvs.iteye.com/blog/412763
手机理财1.0.7 博文链接:https://iwinyeah.iteye.com/blog/213328
NULL 博文链接:https://wy649898543.iteye.com/blog/1423655
博文链接:https://cxlh.iteye.com/blog/245041
NULL 博文链接:https://zw7534313.iteye.com/blog/426799
博文链接:https://avery-leo.iteye.com/blog/213980
NULL 博文链接:https://yizhilong28.iteye.com/blog/1161027
博文链接:https://flare.iteye.com/blog/151376
博文链接:https://knight.iteye.com/blog/75888
博文链接:https://antgreen.iteye.com/blog/245704
博文链接:https://hkme.iteye.com/blog/142511