1、如果struts2是
status2.3.4
在配置文件struts.xml里加上
1 2 3 4 |
< bean
= "org.apache.struts2.dispatcher.multipart.MultiPartRequest" name = "myRequestParser"
= "com.icf.common.base.actions.RequestParseWrapper" scope = "default"
= "true
< constant
= "struts.multipart.handler"
= "myRequestParser"
|
1 2 3 |
public
extends
public
throws
} |
2、如果struts2是
struts2.3.15.1 以后的版本
在struts2.3.15.1后的配置里,struts2的struts-default.xml 里把 struts.multipart.handler 改成了struts.multipart.parser在struts配置文件中加上
1 2 3 4 |
< bean
= "org.apache.struts2.dispatcher.multipart.MultiPartRequest" name = "myRequestParser"
= "com.icf.common.base.actions.RequestParseWrapper" scope = "default"
= "true
< constant
= "
= "myRequestParser"
|
创建一个自己的类RequestParseWrapper
1 2 3 4 |
public
extends
p<span></span>ublic void
throws
} } |
分析原因
struts2的源代码对request对象进行了封装,导致fileList = upload.parseRequest(request);获取不到上传的对象