问题描述
- SmartUpload文件上传报这个错误,求帮忙
-
代码
public class BlacklistManagerAction1 extends BaseAction {@Autowired private IEntityFactory ef; @SuppressWarnings({ "deprecation", "unchecked" }) public ActionForward uploadExcel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ HttpSession session=request.getSession(); UserstbYj user=(UserstbYj)session.getAttribute("user"); StringBuffer pub_sb=(StringBuffer)session.getAttribute("pub_sb");
// as.initStringBuffer(pub_sb);
// String tableName="AD_BLACKLISTTB";
// String fieldNames=(String)session.getAttribute("fieldNames");
// List fieldTypes=(List)session.getAttribute("fieldTypes");
// List fieldCNNames=(List)session.getAttribute("fieldCNNames");
// Integer count=fieldCNNames==null?0:fieldCNNames.size();
Integer count = 11;SmartUpload su = new SmartUpload(); String msg=""; try { su.initialize(request.getSession().getServletContext(),request.getSession(),request,response,null); su.upload(); for(int i=0;i<su.getFiles().getCount();i++){ com.jspsmart.upload.File f=su.getFiles().getFile(i); String fileName=f.getFileName(); if(fileName.trim().indexOf(".xls")==-1){ request.setAttribute("message","对不起,您上传的文件不是excel文件,必须上传.xls类型的文件。"); request.setAttribute("forward","sys_blacklist.do"); return mapping.findForward("GlobalMsg"); } su.save("/tempExcel/"+user.getUserid()); String serverFile= FileUtil.getWebSysPath()+"tempExcel"+"/"+user.getUserid()+"/"+fileName; msg=as.excelToDBBlack(serverFile,count,pub_sb); } } catch (Exception e) { e.printStackTrace(); log.error("上传失败。"+e); request.setAttribute("message", "上传失败,请联系管理员。"); request.setAttribute("forward", "sys_blacklist.do"); return mapping.findForward("GlobalMsg"); } request.setAttribute("message",msg); request.setAttribute("forward", "sys_blacklist.do"); return mapping.findForward("GlobalMsg"); }
}
错误
java.lang.IllegalArgumentException:This path dose not exist
解决方案
java.lang.IllegalArgumentException:This path dose not exist
目录不存在,如果你的路径用\分隔符,记得是双斜杠
时间: 2024-12-27 05:10:19