Struts 2“%”标志和'#“登录OGNL [英] Struts 2 "%" sign and '#" sign in OGNL
问题描述
任何人都可以告诉我如何在STRUTS2 OGNL中使用%和#符号?我谷歌周围,但找不到任何有价值的信息。或者给我一个文件的链接。
Anybody can tell me how to use "%" and "#" sign in STRUTS2 OGNL? I google around, but can't find any valuable info about this.Or give me a link of documentation of this.
谢谢
推荐答案
%
字符强制进行OGNL评估,因此< s:property name = %{foo}/>
将在堆栈中查询 foo
属性。它并不总是需要的(实际上很少),但为了清晰起见,它更容易一致地使用它。
The %
character forces OGNL evaluation, so <s:property name="%{foo}"/>
will query the stack for a foo
property. It's not always required (rarely, in fact), but it's easier to use it consistently for clarity.
#
character访问名为值的堆栈上下文变量,例如,您曾经需要它来访问使用< s:set>
标签。您需要它来访问会话变量之类的内容,例如< s:property name =#session.user.name/>
。
The #
character accesses a named value stack context variable, for example, you used to need it to access a variable created using the <s:set>
tag. You need it to access things like a session variable, like <s:property name="#session.user.name"/>
.
- S2 OGNL Docs
- S2-specific OGNL Docs
- OGNL reference docs
这篇关于Struts 2“%”标志和'#“登录OGNL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!