<bdo id='1OR7w'></bdo><ul id='1OR7w'></ul>

<small id='1OR7w'></small><noframes id='1OR7w'>

        <i id='1OR7w'><tr id='1OR7w'><dt id='1OR7w'><q id='1OR7w'><span id='1OR7w'><b id='1OR7w'><form id='1OR7w'><ins id='1OR7w'></ins><ul id='1OR7w'></ul><sub id='1OR7w'></sub></form><legend id='1OR7w'></legend><bdo id='1OR7w'><pre id='1OR7w'><center id='1OR7w'></center></pre></bdo></b><th id='1OR7w'></th></span></q></dt></tr></i><div id='1OR7w'><tfoot id='1OR7w'></tfoot><dl id='1OR7w'><fieldset id='1OR7w'></fieldset></dl></div>

      1. <tfoot id='1OR7w'></tfoot><legend id='1OR7w'><style id='1OR7w'><dir id='1OR7w'><q id='1OR7w'></q></dir></style></legend>
      2. 如何传递一个Map&lt;ObjectA,List&lt;ObjectB&am

        时间:2023-07-27
          <tbody id='8uxTk'></tbody>

          <small id='8uxTk'></small><noframes id='8uxTk'>

              1. <i id='8uxTk'><tr id='8uxTk'><dt id='8uxTk'><q id='8uxTk'><span id='8uxTk'><b id='8uxTk'><form id='8uxTk'><ins id='8uxTk'></ins><ul id='8uxTk'></ul><sub id='8uxTk'></sub></form><legend id='8uxTk'></legend><bdo id='8uxTk'><pre id='8uxTk'><center id='8uxTk'></center></pre></bdo></b><th id='8uxTk'></th></span></q></dt></tr></i><div id='8uxTk'><tfoot id='8uxTk'></tfoot><dl id='8uxTk'><fieldset id='8uxTk'></fieldset></dl></div>

                <tfoot id='8uxTk'></tfoot><legend id='8uxTk'><style id='8uxTk'><dir id='8uxTk'><q id='8uxTk'></q></dir></style></legend>
                • <bdo id='8uxTk'></bdo><ul id='8uxTk'></ul>

                  本文介绍了如何传递一个Map&lt;ObjectA,List&lt;ObjectB&gt;&gt;在 Struts 2 中执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个事件对象,里面有一个Map>ObjectA是标签,list<;ObjectB> 是表格行.使用以下代码,我可以正确显示表格,但是当我将表单提交到 Action 类时,地图在事件中是 null.

                  I have a event object, inside there is a Map<ObjectA, List<ObjectB>>, the ObjectA is the label, and the list<ObjectB> are table rows. With following code, I can display the tables correctly, but when I submit the form to Action class, the map is null inside the event.

                  JSP 代码:

                  <s:iterator value="event.planMap" var="map" >
                      <h4>Plan Type: <s:property value='key' /></h4>
                      <table id="plan">
                      <s:iterator value="value" status="stat" var="detail" >
                          <tr>
                              <td><input type="text" id="name" name="event.planMap['%{#map.key}'][%{#stat.index}].name" value="<s:property value='name'/>"/></td>
                              <td><input type="text" id="text" name="event.planMap['%{#map.key}'][%{#stat.index}].text" value="<s:property value='text'/>"/></td>
                              <td><input type="text" id="contact" name="event.planMap['%{#map.key}'][%{#stat.index}].contact" value="<s:property value='contact'/>"/></td>
                          </tr>
                          </s:iterator>
                      </table>
                  </s:iterator>
                  

                  @Andrea &Roman,所以我修改了代码.显示表格是正确的,但我得到了错误,它进入了结果输入.如果我删除 planMap,则操作会成功.所以至少我知道错误是 planMap.修改后的代码是:

                  @Andrea & Roman, So I modified the code. displaying the table is correct, but I got error and it went to Result input. If I remove the planMap, the action goes to success. So at least I know the error are the planMap. The modified code is:

                  事件定义:

                  The Event definition:

                  public Event {
                      private Map<Object_A, Object_B> planMap;
                      public Map<Object_A, Object_B> getPlanMap {
                             return this.planMap;
                      }
                  
                      public void setPlanMap(Map<Object_A, Object_B> planMap) {
                             this.planMap = planMap;
                      }
                  }
                  

                  Object_B 定义:

                  The Object_B definition:

                  public Object_B {
                      private List<Object_C> details;
                      
                      public List<Object_C> getDetials() {
                             return this.details;
                      }
                      public void setDetails(List<Object_C> details) {
                             this.details = details;
                      }
                  }
                  

                  JSP代码为:

                  <s:iterator value="event.planMap" status="mStat"  >
                      <h4>Plan Type: <s:property value='key' /></h4>
                      <table id="plan">
                      <s:iterator value="value.details" status="stat">
                      <tr>
                          <td><input type="text" id="name" name="event.planMap['% {#mStat.index}'].details[%{#stat.index}].name" value="<s:property value='name'/>"/></td>
                          <td><input type="text" id="text" name="event.planMap['%{#mStat.index}'].details[%{#stat.index}].text" value="<s:property value='text'/>"/></td>
                          <td><input type="text" id="contact" name="event.planMap['%{#mStat.index}'].details[%{#stat.index}].contact" value="<s:property value='contact'/>"/></td>
                      </tr>
                      </s:iterator>
                  </table>
                  </s:iterator>
                        
                  

                  推荐答案

                  我在以下更改后使其工作.

                  I made it work after the following change.

                  <s:iterator value="event.planMap" status="mStat"  >
                  <h4>Plan Type: <s:property value='key' /></h4>
                  <table id="plan">
                  <s:iterator value="value.details" status="stat">
                  <tr>
                      <td><s:textfield id="name" name="event.planMap['%{key}'].details[%{#stat.index}].name" /></td>
                      <td><s:textfield  id="text" name="event.planMap['%{key}'].details[%{#stat.index}].text" /></td>
                      <td><s:textfield id="contact" name="event.planMap['%{key}].details[%{#stat.index}].contact" /></td>
                  </tr>
                  </s:iterator>
                  

                  这篇关于如何传递一个Map&lt;ObjectA,List&lt;ObjectB&gt;&gt;在 Struts 2 中执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:为什么不能分配 I &lt;?扩展类型>到&lt;类 下一篇:将毫秒转换为分和秒?

                  相关文章

                  最新文章

                        <bdo id='3SMkt'></bdo><ul id='3SMkt'></ul>
                    1. <small id='3SMkt'></small><noframes id='3SMkt'>

                      <i id='3SMkt'><tr id='3SMkt'><dt id='3SMkt'><q id='3SMkt'><span id='3SMkt'><b id='3SMkt'><form id='3SMkt'><ins id='3SMkt'></ins><ul id='3SMkt'></ul><sub id='3SMkt'></sub></form><legend id='3SMkt'></legend><bdo id='3SMkt'><pre id='3SMkt'><center id='3SMkt'></center></pre></bdo></b><th id='3SMkt'></th></span></q></dt></tr></i><div id='3SMkt'><tfoot id='3SMkt'></tfoot><dl id='3SMkt'><fieldset id='3SMkt'></fieldset></dl></div>

                      <tfoot id='3SMkt'></tfoot>
                      <legend id='3SMkt'><style id='3SMkt'><dir id='3SMkt'><q id='3SMkt'></q></dir></style></legend>