日期:2014-05-16 浏览次数:20421 次
<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>
/** * 上传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; }
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(); } });