ExtJS 上传后 下载提示的处理

1.首先是Struts.xml的配置
<action name="uploadexc" method="uploadExcel" class="com.maixin.code.action.UserWorkTimeAction" >   
<interceptor-ref name ="fileUploadStack" >
<!-- <param name="allowedTypes">xls,xlsx</param> -->
<param name="maximumSize">20000000000</param>
</interceptor-ref>
<result type='json'>
<param name="contentType">text/html</param>
<param name="excludeProperties">upload,userWorkTimeSer</param>
</result>
</action>

2.action的写法
	/**
* 上传Excel
* @return
*/
public String uploadExcel(){
try {
Date d = new Date();
System.out.println("uploadFileName = "+this.uploadFileName);
//upload -- wapps 下面的文件夹,用来存放图片
String toSrc = ServletActionContext.getServletContext().getRealPath("upload")+"/"+d.getTime()+getFileExp(this.uploadFileName); //使用時間戳作為文件名
System.out.println("toFile= "+toSrc);
File toFile = new File(toSrc);
writeFile(this.upload,toFile);
userWorkTimeSer.saveExcelWorkTime(upload);
} catch (Exception e) {
e.printStackTrace();
}
return SUCCESS;
}

2.JS的写法
this.uploadform.getForm().submit({
url: 'uploadexc.action',
//waitMsg: 'Uploading your photo...',
success: function(response){

},
failure:function(response){
//上传完后,返回失败,
Ext.getCmp('upwindow').hide();
Ext.getCmp('userWorkTimeGrid').getStore().reload();
}

});

在Struts2 中,上传完成后,返回的JSON时,提示下载,用上面的配置后,不会提示了,Ajax返回的居然是failure,很是奇怪,使用fileBug查看也是正常的,不过算是解决了!呵呵
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值