📄 expressionevaluation.html
字号:
<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Expression Evaluation</title><link href="../docbook.css" rel="stylesheet" type="text/css"><meta content="DocBook XSL Stylesheets V1.65.0" name="generator"><link rel="home" href="index.html" title="OGNL Language Guide"><link rel="up" href="basicExpressions.html" title="Chapter 4. Expressions"><link rel="previous" href="staticFields.html" title="Getting Static Fields"><link rel="next" href="lambdaExpressions.html" title="Pseudo-Lambda Expressions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">Expression Evaluation</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="staticFields.html"><img src="../images/navigation/prev.gif" alt="Prev"></a> </td><th align="center" width="60%">Chapter 4. Expressions</th><td align="right" width="20%"> <a accesskey="n" href="lambdaExpressions.html"><img src="../images/navigation/next.gif" alt="Next"></a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="expressionEvaluation"></a>Expression Evaluation</h2></div></div><div></div></div><p>If you follow an <span class="acronym">OGNL</span> expression with a parenthesized expression, without a dot in front of the parentheses, <span class="acronym">OGNL</span> will try to treat the result of the first expression as another expression to
evaluate, and will use the result of the parenthesized expression as the root object for that evaluation. The result of the first expression may be any object; if it is an AST, <span class="acronym">OGNL</span> assumes it is the parsed form of an
expression and simply interprets it; otherwise, <span class="acronym">OGNL</span> takes the string value of the object and parses that string to get the AST to interpret.</p><p>For example, this expression</p><pre class="programlisting">#fact(30H)</pre><p>looks up the <span class="property">fact</span> variable, and interprets the value of that variable as an <span class="acronym">OGNL</span> expression using the <tt class="classname">BigInteger</tt> representation of <tt class="constant">30</tt> as the
<span class="property">root</span> object. See below for an example of setting the <tt class="varname">fact</tt> variable with an expression that returns the factorial of its argument. Note that there is an ambiguity in <span class="acronym">OGNL</span>'s
syntax between this double evaluation operator and a method call. <span class="acronym">OGNL</span> resolves this ambiguity by calling anything that looks like a method call, a method call. For example, if the current object had a fact property
that held an <span class="acronym">OGNL</span> factorial expression, you could not use this approach to call it</p><pre class="programlisting">fact(30H)</pre><p>because <span class="acronym">OGNL</span> would interpret this as a call to the <span class="property">fact</span> method. You could force the interpretation you want by surrounding the property reference by parentheses:</p><pre class="programlisting">(fact)(30H)</pre></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="staticFields.html"><img src="../images/navigation/prev.gif" alt="Prev"></a> </td><td align="center" width="20%"><a accesskey="u" href="basicExpressions.html"><img src="../images/navigation/up.gif" alt="Up"></a></td><td align="right" width="40%"> <a accesskey="n" href="lambdaExpressions.html"><img src="../images/navigation/next.gif" alt="Next"></a></td></tr><tr><td valign="top" align="left" width="40%">Getting Static Fields </td><td align="center" width="20%"><a accesskey="h" href="index.html"><img src="../images/navigation/home.gif" alt="Home"></a></td><td valign="top" align="right" width="40%"> Pseudo-Lambda Expressions</td></tr></table></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -