我们目前正在将我们的应用程序从struts 1迁移到struts 2模块,我们正在使用struts2-strut1插件。
每件事似乎都运行良好,期待文件我们将文件属性值设为NULL。
我们已经检查过所有标签下面的所有标签
JSP code Snippet
<s:form name="uploadForm" namespace="/struts2" action="upload" enctype="multipart/form-data" method="post">
<s:file name="doc" cssClass="genTextValues"/>
<s:submit/>
</s:form>
Java Action表单
public class UploadForm extends ActionForm {
private FormFile doc;
public FormFile getDoc() {
return doc;
}
// its not setting gives null in action form
public void setDoc(FormFile doc) {
this.doc = doc;
}
}
Struts.xml映射
<interceptor name="uploadForm" class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor">
<param name="scope">request</param>
<param name="className">com.form.UploadForm</param>
<param name="name">uploadForm</param>
</interceptor>
<interceptor-stack name="iUploadForm">
<interceptor-ref name="staticParams" />
<interceptor-ref name="uploadForm" />
<interceptor-ref name="modelDriven" />
<interceptor-ref name="basicStack" />
</interceptor-stack>
<action name="uploadDoc" class="org.apache.struts2.s1.Struts1Action">
<param name="className">com.test.action.UploadAction</param>
<interceptor-ref name="iUploadForm"/>
<result name="Success" type="tiles">Success</result>
</action>
我们已经添加了必需的jar,见下文:
commons-fileupload.jar
struts.jar
struts2-struts1-plugin.jar
struts2-core.jar (2.16)
commons-io2.2.jar
其他必需的罐子
答案 0 :(得分:0)
fileUpload
中没有interceptor-stack
拦截器。
<interceptor-stack name="iUploadForm">
<interceptor-ref name="staticParams" />
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="uploadForm" />
<interceptor-ref name="modelDriven" />
<interceptor-ref name="basicStack" />
</interceptor-stack>