【问题标题】:Issue passing list of VO from JSP to action using struts 1.2.9使用 struts 1.2.9 将 VO 列表从 JSP 传递到操作
【发布时间】:2013-09-09 00:14:47
【问题描述】:

我有一个 JSP,它有两个标签、四个复选框和四个文本字段。由于这是一组数据并且可以是动态的,因此这些字段存储在一个值对象中并存储在一个列表中,并将此列表传递给操作类。

问题是,当提交表单时,我无法通过表单将更新的值列表获取到 Struts 中。我正在使用 Struts 1.2.9

下面JSP的代码sn-p:

<logic:iterate name="monthlyGainLossForm" property="ptcList" id="ptc"> 
<mf:td> 
  <html:text name="ptc" property="ptcName" /> 
  <html:hidden name ="ptc" property="ptcName"/> 
</mf:td> 
<mf:td>
  <html:text name="ptc" property="ptcActive" />
</mf:td> 
<html:hidden name ="ptc" property="ptcActive"/> 
<mf:td>
  <html:checkbox name="ptc" disabled="false" property="msaPtcLtcGLType" styleClass="input"/> 
  <html:hidden name ="ptc" property="msaPtcLtcGLType"/>
</mf:td> 
<mf:td>
  <html:text name="ptc" readonly="true" property="msaPtcLtcGLAmt" styleClass="input"/> 
  <html:hidden name ="ptc" property="msaPtcLtcGLType"/>
</mf:td> 

【问题讨论】:

  • 我注意到,在格式化您的代码时,您似乎有一个 结束标记放置不正确;不应该是之后 &lt;html:hidden name ="ptc" property="ptcActive"/&gt;,而不是之前?我不知道这是否是问题,但至少它是 a 问题...
  • 您要么没有提交,要么无法编译。你尝试了什么?你有一个具体的问题吗?为了尽快获得更好的帮助,请发布SSCCE

标签: java struts


【解决方案1】:

您不应同时对同一字段使用两种输入类型:html:texthtml:hidden。删除其中一个您不需要的。

所以应该是这样的:

<mf:td> 
  <html:text name="ptc" property="ptcName" /> 
</mf:td> 

其余字段也一样。

【讨论】:

    【解决方案2】:

    代码 sn-p 不是完整的。但问题是价值观没有被付诸行动。我通过将下面的代码行放在 JSP 中来修复它。这样,我将通过实际的形式获得价值。

            <logic:iterate name="monthlyGainLossForm" property="ptcList" id="productTaxCat">
            <html:hidden name="productTaxCat" property="ptcId" indexed="true" />
            <html:hidden name="productTaxCat" property="ptcName" indexed="true" />
            <html:hidden name="productTaxCat" property="ptcActive" indexed="true" />
            <mf:tr>
                <mf:td><bean:write name="productTaxCat" property="ptcName"/></mf:td>
                <mf:td><bean:write name="productTaxCat" property="ptcActive"/></mf:td>
                <mf:td><html:checkbox name="productTaxCat" property="msaPtcLtcGLType" styleClass="input" indexed="true"/></mf:td>
                <mf:td><html:text name="productTaxCat" property="msaPtcLtcGLAmt" styleClass="label" style="width:100px;vertical-align:middle;" disabled="true" indexed="true"/></mf:td>
                <mf:td><html:checkbox name="productTaxCat" property="msaMthlyStcGLType" styleClass="input" indexed="true"/></mf:td>
                <mf:td><html:text name="productTaxCat" property="msaMthlyStcGLAmt" disabled="true" styleClass="label" style="width:100px;vertical-align:middle;" indexed="true"/></mf:td>
                <mf:td><html:checkbox name="productTaxCat" property="nonMsaPtcGLType" styleClass="input" indexed="true"/></mf:td>
                <mf:td><html:text name="productTaxCat" property="nonMsaPtcGLAmt" disabled="true" styleClass="label" style="width:100px;vertical-align:middle;" indexed="true"/></mf:td>
                <mf:td><html:checkbox name="productTaxCat" property="nonMsaStcGLType" styleClass="input" indexed="true"/></mf:td>
                <mf:td><html:text name="productTaxCat" property="nonMsaStcGLAmt" disabled="true" styleClass="label" style="width:100px;vertical-align:middle;" indexed="true"/></mf:td>
            </mf:tr>
            </logic:iterate>
    

    感谢所有有用的 cmets。

    【讨论】:

      猜你喜欢
      • 2013-06-11
      • 2012-06-04
      • 1970-01-01
      • 2015-04-03
      • 2013-12-07
      • 1970-01-01
      • 2014-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多