原因:
原因是你web.xml中,struts2的过滤器,把HttpServletRequest变成了MultiPartRequest,所以 upload.parseRequest(request); 必然是null。 解决方法是,在web.xml中 将/* 改成.action
----------------------------------------
其他做法:
个servlet.Filter,并且把它的filter次序放到struts2的filter次序之前。主要源码如下:
这里先用StrutsRequestWrapper来给他wrapper一次,这样在经过struts2的filter的时候就不会有问题了。为啥呢?可以自己看看这个类
org.apache.struts2.dispatcher.Dispatcher里面的wrapRequest方法,有这么个判断:
// don't wrap more than once
if (request instanceof StrutsRequestWrapper) {
return request;
}
可以查看 http://auzll.iteye.com/blog/919981 具体解决方法