Struts 2“%"签名和“#"登录 OGNL

Struts 2 quot;%quot; sign and #39;#quot; sign in OGNL(Struts 2“%签名和“#登录 OGNL)

本文介绍了Struts 2“%"签名和“#"登录 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.

# 字符访问 named 值堆栈上下文变量,例如,您曾经需要它来访问使用 <s 创建的变量:设置>标签.您需要它来访问诸如会话变量之类的东西,例如 <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 文档
  • 特定于 S2 的 OGNL 文档
  • OGNL 参考文档

这篇关于Struts 2“%"签名和“#"登录 OGNL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Struts 2“%"签名和“#"登录 OGNL

基础教程推荐