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

        <bdo id='Ulhd7'></bdo><ul id='Ulhd7'></ul>

      <legend id='Ulhd7'><style id='Ulhd7'><dir id='Ulhd7'><q id='Ulhd7'></q></dir></style></legend>

        Struts2 将列表数据从 JSP 发送到 Action 类:替代方式

        Struts2 sending list data from JSP to Action class: alternative way(Struts2 将列表数据从 JSP 发送到 Action 类:替代方式)

          <tfoot id='pdH7O'></tfoot>
        • <legend id='pdH7O'><style id='pdH7O'><dir id='pdH7O'><q id='pdH7O'></q></dir></style></legend>

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

            • <bdo id='pdH7O'></bdo><ul id='pdH7O'></ul>
              1. <i id='pdH7O'><tr id='pdH7O'><dt id='pdH7O'><q id='pdH7O'><span id='pdH7O'><b id='pdH7O'><form id='pdH7O'><ins id='pdH7O'></ins><ul id='pdH7O'></ul><sub id='pdH7O'></sub></form><legend id='pdH7O'></legend><bdo id='pdH7O'><pre id='pdH7O'><center id='pdH7O'></center></pre></bdo></b><th id='pdH7O'></th></span></q></dt></tr></i><div id='pdH7O'><tfoot id='pdH7O'></tfoot><dl id='pdH7O'><fieldset id='pdH7O'></fieldset></dl></div>
                    <tbody id='pdH7O'></tbody>
                  本文介绍了Struts2 将列表数据从 JSP 发送到 Action 类:替代方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在向一位同事解释如何使用索引从 JSP 页面获取列表数据以返回到操作类,如 这里和这里.他不太明白,自己摸索了一下,直到他突然完全不使用索引就让它工作了!

                  I was explaining to a colleague the way of getting list data from a JSP page to back to the action class by using indices as explained here and here. He didn't quite understand and fumbled a bit on his own until he suddenly he made it work by not using indices at all!

                  在他的 JSP 页面中,他有:

                  In his JSP page he had:

                  <input type="checkbox" name="contactNameList" value="someValue1">
                  <input type="checkbox" name="contactNameList" value="someValue2">
                  <input type="checkbox" name="contactNameList" value="someValue3">
                  <input type="checkbox" name="contactNameList" value="someValue4">
                  

                  在他的动作课上,他有合适的"二传手:

                  In his action class he had the 'appropiate' setters:

                  public List<String> getContactNameList()
                  
                  public void setContactNameList(List<String> list)
                  

                  我很困惑为什么会这样.我认为这是可行的,因为他正在发送非 bean 数据(在本例中为字符串),并且 Struts2/OGNL 中内置了一个智能功能,可以将值附加到列表而不是覆盖他们.

                  I'm baffled as to why this work. I think this works because he is sending non-bean data (in this case strings) and there is an intelligence build into Struts2/OGNL to append values to lists rather than overwrite them.

                  任何人都可以详细解释这个无索引"案例的幕后情况吗?字符串列表是如何用上面的代码片段实例化和填充的?

                  Can anybody explain with great detail what is going behind the hood in this "no indices" case? How is the list of strings instantiated and populated with the snippets above?

                  推荐答案

                  你应该明白 bean 数据而不是 bean 数据是作为参数传递给动作的.参数有一个结构,如果你实现 ParameterAware,你可以找到它.

                  You should understand that bean data and not bean data are passed as parameters to the action. The parameters has a structure that you can find if you implement ParameterAware.

                  请注意,将返回给定名称的所有参数值,因此地图中对象的类型是java.lang.String[].

                  Note that all parameter values for a given name will be returned, so the type of the objects in the map is java.lang.String[].

                  然后 XWork Type Conversion 会尽力将此映射转换为 beans 属性.请参阅内置类型转换支持.

                  Then XWork Type Conversion make its best to convert this map to beans properties. See Built in Type Conversion Support.

                  框架中的常规类型转换是透明的.一般来说,您需要做的就是确保 HTML 输入的名称可以在 OGNL 表达式中使用.(HTML 输入是表单元素和其他GET/POST 参数.)

                  Routine type conversion in the framework is transparent. Generally, all you need to do is ensure that HTML inputs have names that can be used in OGNL expressions. (HTML inputs are form elements and other GET/POST parameters.)

                  在没有索引的情况下,参数被映射在一个键下,而不是索引名称在它们自己的名称下使用.

                  In the no indexes case parameters are mapped under the one key, rather than indexed names are used under their own names.

                  这篇关于Struts2 将列表数据从 JSP 发送到 Action 类:替代方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)

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

                  • <bdo id='tFaTQ'></bdo><ul id='tFaTQ'></ul>
                      <tbody id='tFaTQ'></tbody>

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

                        <legend id='tFaTQ'><style id='tFaTQ'><dir id='tFaTQ'><q id='tFaTQ'></q></dir></style></legend>