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

      2. <legend id='iQTKl'><style id='iQTKl'><dir id='iQTKl'><q id='iQTKl'></q></dir></style></legend><tfoot id='iQTKl'></tfoot>

        &lt;s:选择&gt;具有动态列表名称

        lt;s:selectgt; with dynamic list name(lt;s:选择gt;具有动态列表名称)

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

              <tbody id='MbgDu'></tbody>
          1. <legend id='MbgDu'><style id='MbgDu'><dir id='MbgDu'><q id='MbgDu'></q></dir></style></legend>

            <small id='MbgDu'></small><noframes id='MbgDu'>

                • <bdo id='MbgDu'></bdo><ul id='MbgDu'></ul>
                • 本文介绍了&lt;s:选择&gt;具有动态列表名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想遍历包含 <s:select> 列表源名称的字符串列表,但 HTML 输出与预期不符:这是列表的名称是显示,而不是内容.

                  I want to iterate over a list of strings containing names for <s:select> list source, but the HTML output is not as expected : it's the name of the list that is display, not the content.

                  我的操作代码:

                  My Action code:

                  public class DescriptionTabArchiveAction extends ActionSupport {
                      private List<String> vegetables = new ArrayList<String>();
                      private List<String> devices = new ArrayList<String>();
                  
                      // contain "vegetables" and "devices".
                      private List<String> selectList = new ArrayList<String>();
                  
                      @Action("multipleSelect")
                      public String multipleSelect() {
                                  vegetables.add("tomato");
                                  vegetables.add("potato");
                  
                                  devices.add("mouse");
                                  devices.add("keyboard");
                  
                                  selectList.add("vegetables");
                                  selectList.add("devices");
                  
                          return SUCCES;
                      }
                  
                         // getters and setters
                  }
                  

                  JSP:

                  <s:iterator value="selectList" var="listName">
                  
                      <s:select list="%{#listName}" />
                  
                      <!-- I tried with this line too : same behaviour. -->
                      <%-- <s:select list="#listName" /> --%>
                  </s:iterator>
                  

                  我得到了什么(html 输出):

                  <select name="" id="">
                      <option value="vegetables">vegetables</option>
                  </select>
                  <select name="" id="">
                      <option value="devices">devices</option>
                  </select>
                  

                  我的期望(html 输出):

                  <select name="" id="">
                      <option value="tomato">tomato</option>
                      <option value="potato">potato</option>
                  </select>
                  <select name="" id="">
                      <option value="mouse">mouse</option>
                      <option value="keyboard">keyboard</option>
                  </select>
                  

                  我的问题:

                  如何动态迭代字符串列表以获得多个具有不同列表源的 <s:select>?

                  How can I dynamically iterate over a list of string to have multiple <s:select> with different list source?

                  推荐答案

                  使用 Map 代替 List

                  private Map<String, List<String>> selectMap = new HashMap<>();
                  //getter and setter here
                  
                  @Action("multipleSelect")
                  public String multipleSelect() {
                      vegetables.add("tomato");
                      vegetables.add("potato");
                  
                      devices.add("mouse");
                      devices.add("keyboard");
                  
                      selectMap.put("vegetables", vegetables);
                      selectMap.put("devices", devices);
                  
                      return SUCCESS;
                  }
                  

                  修改迭代器以使用地图

                  <s:iterator value="selectMap">    
                      <s:select list="%{value}" />
                      ...
                  </s:iterator>
                  

                  这篇关于&lt;s:选择&gt;具有动态列表名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                  Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                  About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                  What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                  Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                  Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)
                    <bdo id='WWRDD'></bdo><ul id='WWRDD'></ul>
                      <legend id='WWRDD'><style id='WWRDD'><dir id='WWRDD'><q id='WWRDD'></q></dir></style></legend>
                      • <i id='WWRDD'><tr id='WWRDD'><dt id='WWRDD'><q id='WWRDD'><span id='WWRDD'><b id='WWRDD'><form id='WWRDD'><ins id='WWRDD'></ins><ul id='WWRDD'></ul><sub id='WWRDD'></sub></form><legend id='WWRDD'></legend><bdo id='WWRDD'><pre id='WWRDD'><center id='WWRDD'></center></pre></bdo></b><th id='WWRDD'></th></span></q></dt></tr></i><div id='WWRDD'><tfoot id='WWRDD'></tfoot><dl id='WWRDD'><fieldset id='WWRDD'></fieldset></dl></div>

                          <small id='WWRDD'></small><noframes id='WWRDD'>

                          <tfoot id='WWRDD'></tfoot>

                            <tbody id='WWRDD'></tbody>