【问题标题】:Accessing Struts2 value stack from inside displayTag column element从 displayTag 列元素内部访问 Struts2 值堆栈
【发布时间】:2014-03-21 15:04:12
【问题描述】:

我想通过访问 Struts 2 值堆栈中的属性来使 titleKey 属性参数化。所以,我想做这样的事情:

<display:table name="myListOfObjects" id="myId" requestURI="/myAction.action" pagesize="10">
    <display:column property="myProperty" titleKey="my.internationalyzed.i18n.key.myProperty.<s:property value='anotherObject.aProperty'/>" />
    ...

如您所见,我想在我的操作中将属性访问到暴露的对象中

<s:property value='anotherObject.aProperty'/>

并将值放入titleKey 元素中。

如果我这样做,结果是一个表格列,其中一个未解析的my.internationalyzed.i18n.key.myProperty 字符串作为标题。换句话说,&lt;s:property&gt; 标记不会在 &lt;display:column&gt; 元素内进行解释。

但是如果我把

<s:property value='anotherObject.aProperty'/>

&lt;display:table&gt; 元素之外,它被正确解析并且结果值显示在页面上,因此该属性被正确公开和增值。 您知道如何从 &lt;display:column&gt; 元素内部访问在操作中公开的属性吗?

【问题讨论】:

    标签: jsp struts2 displaytag valuestack


    【解决方案1】:

    你可以在你的非struts 标签中使用JSP EL 表达式,所以当在请求范围内查看时,表达式会要求请求公开值栈。例如

    <display:column property="myProperty" titleKey="my.internationalyzed.i18n.key.myProperty.${anotherObject.aProperty}" />
    

    【讨论】:

      猜你喜欢
      • 2020-06-04
      • 2015-05-16
      • 1970-01-01
      • 1970-01-01
      • 2015-07-04
      • 2018-09-20
      • 2019-10-16
      • 2022-11-02
      • 1970-01-01
      相关资源
      最近更新 更多