今天在页面提交到servlet上传时,遇到一小问题,
最后原因是被 web.xml中的 Filter过滤掉了
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(tempPath));
ServletFileUpload upload = new ServletFileUpload(factory);
List<FileItem> fileItems = upload.parseRequest(req);
// 这里 fileItems一直为空
最后原因是被 web.xml中的 Filter过滤掉了
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<!-- <url-pattern>/*</url-pattern> -->
<url-pattern>*.action</url-pattern>
</filter-mapping>