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

    1. <tfoot id='he7X5'></tfoot>

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

      • <bdo id='he7X5'></bdo><ul id='he7X5'></ul>

      1. <legend id='he7X5'><style id='he7X5'><dir id='he7X5'><q id='he7X5'></q></dir></style></legend>
      2. Struts 2 - 了解 OGNL 和 params 拦截器之间的工作

        Struts 2 - Understanding the working between OGNL and params interceptor(Struts 2 - 了解 OGNL 和 params 拦截器之间的工作)

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

            <tbody id='zjdJX'></tbody>

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

                • <tfoot id='zjdJX'></tfoot>
                • 本文介绍了Struts 2 - 了解 OGNL 和 params 拦截器之间的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是 Struts 2 的新手.我正在从 Struts2 In Action 一书中学习它.我很难理解 OGNL 中的一些概念,如下 -

                  I am new to Struts 2. I am studying it from the book Struts2 In Action. I am having difficulty in understanding some concepts in OGNL which are as follows-

                  1. 我们知道params 拦截器将数据从请求参数移动到ValueStack 中的action 对象.现在在阅读时,我遇到了一句话,上面写着——这项工作的棘手部分是将参数的名称映射到 ValueStack 上的实际属性.这就是 OGNL 的用武之地.params 拦截器解释请求参数名称作为 OGNL 表达式以在 ValueStack 上定位正确的目标属性".

                  1. We know that params interceptor moves the data from the request parameters to the action object in ValueStack. Now while reading, I came upon a line that says- "The tricky part of the job is mapping the name of the parameter to an actual property on the ValueStack. This is where OGNL comes in. The params interceptor interprets the request parameter name as an OGNL expression to locate the correct destination property on the ValueStack".

                  问题 1) 这里的解释"是什么意思?是 params 拦截器将请求参数转换为一些 OGNL 表达式,然后 OGNL 表达式提供到 ValueStack 中的属性的映射,还是意味着其他什么?

                  Question 1) Here, what does "interprets" mean? Is it that params interceptor translates the request parameter into some OGNL expression and then OGNL expression provides mapping to the properties in ValueStack OR does it mean something else?

                  当 result 开始渲染过程时,Struts 2 标签通过使用 OGNL 表达式引用特定值从 ValueStack 中检索数据.

                  When result start its rendering process, the Struts 2 tags retrieve data from the ValueStack by referencing specific values with OGNL expressions.

                  问题2)所以标签采用OGNL表达式,但是数据是如何移动的?早些时候,params 拦截器是移动数据的拦截器,但现在没有 params 拦截器.那么数据是如何被移动的呢?

                  Question 2) So the tags take OGNL expressions, but how is the data being moved? Earlier, params interceptor was the one that moved the data but now there is no params interceptor. So how is the data being moved?

                  推荐答案

                  答案#1

                  参数名称是 OGNL 表达式.这是 ConventionOverConfiguraiton 的一个例子.如果我们同意使参数的名称成为可以访问 javabeans 属性的有效 OGNL 表达式,那么很容易将该名称作为表达式传递给 OGNL.这当然是在内部完成的;除非您正在破解 Struts 2 代码的那一部分,否则您实际上不需要知道它是如何工作的.

                  The parameter names ARE OGNL expressions. It's a case of ConventionOverConfiguraiton. If we agree to make the names of the parameters valid OGNL expressions that can access a javabeans property, then it's easy to simply hand that name over to OGNL as an expression. This is done internally of course; you don't really need to know how it works unless you are hacking on that part of the Struts 2 code.

                  答案 #2

                  动作对象位于 ValueStack 的顶部.ValueStack 是可用的,因为它作为 ThreadLocal ActionContext 的一部分存在,可以从在同一线程上执行的任何代码中获得.由于 Web 应用程序使用单个线程来处理请求,我们知道结果层将能够到达 ValueStack 以检索数据,再次使用标记中的名称作为 OGNL 表达式.

                  The action object is sitting on top of the ValueStack. The ValueStack is avaible, via it's existence as part of the ThreadLocal ActionContext, from any code executing on the same thread. Since a web app uses a single thread to handle the processing of a request, we know that the Result layer will be able to get to the ValueStack to retrieve the data, again going using the name in the tag as a OGNL expression.

                  注意:

                  所有这一切的关键部分是 ValueStack 可用于在同一线程上执行的任何代码.这允许所有处理单个请求的代码都可以访问 ValueStack,它们可以通过 ThreadLocal ActionContext 获得(如果您不理解,请阅读 Java 的 ThreadLocal 类).

                  The key part of all of this is the fact that the ValueStack is available to any code executing on the same thread. This allows all code processing a single request to have access to the ValueStack, which they can obtain via the ThreadLocal ActionContext ( read about Java's ThreadLocal class if you don't understand ).

                  params 拦截器然后可以尝试使用参数名称作为 OGNL 表达式将数据写入 ValueStack(服务器作为 OGNL 上下文 - 如果您不理解,请再次阅读有关 OGNL API 的信息).然后,处理响应呈现的 Result 类中的代码可以将标签库中的各种名称和值解释为 OGNL 表达式,以从 ValueStack 读取数据.

                  The params interceptor can then try to use the param name as an OGNL expression to write data to the ValueStack ( which servers as the OGNL context -- again read about the OGNL API if you don't understand ). Then the code in the Result classes that handle the rendering of the response can interpret the various names and values from the tag libraries as OGNL expressions to READ data from the ValueStack.

                  这篇关于Struts 2 - 了解 OGNL 和 params 拦截器之间的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 表达式)

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

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

                    <tfoot id='a5Y6G'></tfoot>

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