struts:多部分参数丢失

问题描述

我正在修改一个用 struts 制作的应用程序。

我创建了一个带有文件上传表单的简单页面。但是换页时,参数丢失。如果我删除 enctype="multipart/form-data" 一切正常。

这是在struts-config.xml中定义页面的方式

<action 
    path="/MyElementEdit" 
    type="com.....MyElementAction" 
    name="MyElementForm"
    parameter="action" 
    scope="session" 
    validate="false"
>
    ...
    <forward name="closeEdit" path=".geralCloseEdit" redirect="false"/>
 </action>

JSP 表单

<html:form action="informationGuideEdit" method="post"  enctype="multipart/form-data">
    <input type='hidden' name='ParaM' value='VALUE'/>
    ....
</html:form>
<a href="javascript:saveElement();" class="btn btn-primary"><fmt:message key="button.save"/></a>
function newElement() {
    document.forms[0].action.value='save';
    document.forms[0].submit();
}   

页面重定向的逻辑

    public ActionForward save(
            ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
                    throws Exception {

        ....

        form.reset(mapping,request);
        return mapping.findForward("closeEdit");
}

无参数到达的jsp页面也是如此(generalCloseEdit.jsp)

<%
...
valueParam = request.getParameter('ParaM');
%>  

在这种情况下 valueParam 为空,但如果我删除 enctype = "multipart / form-data" 一切正常

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)