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

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

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

    <tfoot id='aH9T8'></tfoot>
      <bdo id='aH9T8'></bdo><ul id='aH9T8'></ul>

    1. 配置请求参数以将操作分配给 bean 的字段

      configure request param for action to be assigned to fields of bean(配置请求参数以将操作分配给 bean 的字段)

          <legend id='wHcbM'><style id='wHcbM'><dir id='wHcbM'><q id='wHcbM'></q></dir></style></legend>
            <tbody id='wHcbM'></tbody>
            <bdo id='wHcbM'></bdo><ul id='wHcbM'></ul>
          • <tfoot id='wHcbM'></tfoot>
            <i id='wHcbM'><tr id='wHcbM'><dt id='wHcbM'><q id='wHcbM'><span id='wHcbM'><b id='wHcbM'><form id='wHcbM'><ins id='wHcbM'></ins><ul id='wHcbM'></ul><sub id='wHcbM'></sub></form><legend id='wHcbM'></legend><bdo id='wHcbM'><pre id='wHcbM'><center id='wHcbM'></center></pre></bdo></b><th id='wHcbM'></th></span></q></dt></tr></i><div id='wHcbM'><tfoot id='wHcbM'></tfoot><dl id='wHcbM'><fieldset id='wHcbM'></fieldset></dl></div>

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

                本文介绍了配置请求参数以将操作分配给 bean 的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用 www.datatables.net.JS 框架在表格中显示数据.它具有服务器模式,并在此模式下发送大量参数.

                I am using www.datatables.net. JS framework to show data in tables. It has server mode and it sends a lot of params during this mode.

                示例:sortColumnsortType(asc,desc)、过滤值、pagenumitemsonpage等开.

                Example: sortColumn, sortType(asc,desc), filter values, pagenum, itemsonpage and so on.

                所以我在行动中处理它.我分配给每个请求参数字段,它工作正常.

                So i handle it in action. i assign to each request param field in action and it work fine.

                但现在我有几张桌子.所以我必须采取不同的行动,但要求参数相同,而且有很多.将粘贴代码从一个操作复制到另一个操作不是一个好主意.

                But now i have several table. So i have to make different actions but request params same and there are a lots of them. It is not a good idea to copy paste code from one action to another.

                所以我确实实现了一个 DatatableParamBean,其中包含正常工作所需的所有参数.

                So i did implement a DatatableParamBean which contain all params needed to work properly.

                问题是params这样发送iSortColumniDisplayTotalLengthiTotalItems等但我需要将它们分配给 bean 字段.

                problem is that params send this way iSortColumn, iDisplayTotalLength, iTotalItems and so on but i need to them to be assigned to bean fields.

                bean.iSortColumn, bean.iDisplayTotalLength and so on.
                

                考虑到 DatatableParamBean 在我的操作类中引用为bean";

                Consider that DatatableParamBean has reference in my action class as 'bean';

                是否有办法覆盖分配请求参数值的默认机制?我现在找到的唯一解决方案是使用所有这些参数创建一个动作说 DatatableAction 类,并在我需要处理 dataatble 时创建一个新动作,使用从 DatatableAction

                If there is a way to override default mechanism of assigning request param values? Only solution i found for now is to create an action say DatatableAction class with all this params and create an new action if i need to handle dataatble, using extending from DatatableAction

                推荐答案

                这是将 bean 关联或聚合到操作类的常用方法.动作类属性可以通过具有属性访问器的名称直接使用.可以通过 OGNL 访问嵌套的 beans 属性,方法是指定适当的 OGNL 表达式,该表达式是属性的 path.假设所有属性访问器都没有对 bean 的 null 引用.这可以通过为属性提供相应的 getter 和 setter 并在必要时初始化 bean 引用来实现.因此,bean.iSortColumnbean.iDisplayTotalLength 是设置/获取 bean 属性的有效 OGNL 表达式.但是您需要在操作中对其进行初始化.像这样

                This is usual way to associate or aggregate a bean to the action class. The action class properties can be used directly by name that have property accessors. Nested beans properties are accessible via OGNL by specifying proper OGNL expression which is a path to the property. Assumed all properties accessors have not null references to beans. That could be achieved via providing corresponding getters and setters to properties and initializing bean references if necessary. So, bean.iSortColumn, bean.iDisplayTotalLength are valid OGNL expressions to set/get the bean properties. But you need to initialize it in the action. Like this

                private Bean bean = new Bean();
                
                public Bean getBean() { return bean; }
                

                参考资料:

                • 要熟悉 OGNL 的工作原理,您可以阅读 OGNL 基础知识.
                • 基本 OGNL 参考资料,包括指向 OGNL 语言指南的链接.李>
                • To be familiar how OGNL works you can read in the OGNL Basics.
                • The base OGNL reference including a link to the OGNL language guide.

                这篇关于配置请求参数以将操作分配给 bean 的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 表达式)
              1. <i id='ZW6Co'><tr id='ZW6Co'><dt id='ZW6Co'><q id='ZW6Co'><span id='ZW6Co'><b id='ZW6Co'><form id='ZW6Co'><ins id='ZW6Co'></ins><ul id='ZW6Co'></ul><sub id='ZW6Co'></sub></form><legend id='ZW6Co'></legend><bdo id='ZW6Co'><pre id='ZW6Co'><center id='ZW6Co'></center></pre></bdo></b><th id='ZW6Co'></th></span></q></dt></tr></i><div id='ZW6Co'><tfoot id='ZW6Co'></tfoot><dl id='ZW6Co'><fieldset id='ZW6Co'></fieldset></dl></div>
                • <small id='ZW6Co'></small><noframes id='ZW6Co'>

                    <tbody id='ZW6Co'></tbody>

                        <legend id='ZW6Co'><style id='ZW6Co'><dir id='ZW6Co'><q id='ZW6Co'></q></dir></style></legend>
                          <bdo id='ZW6Co'></bdo><ul id='ZW6Co'></ul>
                          <tfoot id='ZW6Co'></tfoot>