List items = upload.parseRequest(request),items为空
jsp的form里面这样写的:
<html:form method="post" action="/t04_report/t04_report_list.do" enctype="multipart/form-data">
Action里面这样写的:
private ActionForward performImportReports(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) {
DiskFileItemFactory factory = new DiskFileItemFactory();
// 设置内存缓冲区,超过后写入临时文件
factory.setSizeThreshold(10240000);
// 设置临时文件存储位置
String base = this.getServletContext().getRealPath("/")+"files";
System.out.println("--------base----------------->"+base);
File file = new File(base);
System.out.println("------------>"+file.exists());
if(!file.exists()){
file.mkdirs();
}
factory.setRepository(file);
ServletFileUpload upload = new ServletFileUpload(factory);
// 设置单个文件的最大上传值
upload.setFileSizeMax(10002400000l);
// 设置整个request的最大值
upload.setSizeMax(10002400000l);
upload.setHeaderEncoding("gb2312");
try {
List<?> items = upload.parseRequest(request);
System.out.println("itemsSize--------------->"+items.size());//值为0,纠结啊。。。
FileItem item = null;
String fileName = null;
for (int i = 0 ;i < items.size(); i++){
item = (FileItem) items.get(i);
fileName = base + File.separator + item.getName();
System.out.println("------------------>"+item.getFieldName());
// 保存文件
System.out.println("--------fileName-------->"+fileName);
if (!item.isFormField() && item.getName().length() > 0) {
item.write(new File(fileName));
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
List items = upload.parseRequest(request),items为空,不知道怎么办了,求大哥们帮忙解决啊!
------解决方案--------------------