62,614
社区成员
发帖
与我相关
我的任务
分享
<action name="add_standardFiles" class="standardFilesAction" method="addStandardFiles">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">text/plain,image/jpeg,application/msword</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="success" type="redirectAction">standardFiles</result>
<result name="successAndContinueAdd" type="chain">load_add_standardFiles</result>
<result name="fail" >/standardfiles/add_standardfiles.jsp</result>
<result name="input">/error.jsp</result>
</action>
<td>文件名称:</td>
<td><input type="file" name="myFile" id="myFile" /></td>
public String addStandardFiles(){
try {
if(myFile==null){
return "fail";
}
String sFileCode = DBProcedure.getCreateTableNo(1);
standardFiles.setFileCode(sFileCode);
standardFiles.setFileObject(myFile);//对象获得文件信息
standardFiles.setFileName(myFileFileName);//对象获得文件名称
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
standardFiles.setStatusDate(sdf.format(new Date()));
HttpSession session = ServletActionContext.getRequest().getSession();
standardFiles.setUserCode(session.getAttribute("staffCode").toString());
standardFiles.setUserName(session.getAttribute("username").toString());
standardFiles.setStatus("1");
standardFilesService.addStandardFiles(standardFiles);
//保存成功后,再打开新增页面等待下一次新增
return SUCCESS;
//System.out.println("N...");
//return SUCCESS;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return SUCCESS;
}