Struts2 MessageResources in Apache Tiles

两盒软妹~` 提交于 2019-12-02 06:37:56

问题


I'm trying unsuccessfully to use a Struts2 message resource in a tiles 2.1.4 expression. For example the following resource is available in the JSP...

<s:text name="htmlheadHeading1"/><br/>

... but when I attempt to use the same resource in the tiles definition...

<put-attribute name="title" expression="${htmlheadHeading1}" />

... I get the error...

ELResolver cannot handle a null base Object with identifier 'htmlheadHeading1'

... Is there any way to do this??


回答1:


This solution does not use tiles expressions but will work if you need to display localized text in JSP when key is passed through tiles definitions.

In tiles definition:

<put-attribute name="title" value="htmlheadHeading1" />

In your JSP then use Struts2 <s:set> tag to set title from tiles definition to local variable and then use it in <s:text> tag.

<s:set var="title">
  <tiles:getAsString name="title" ignore="true"/>
</s:set>
<s:text name="%{#title}"/>


来源:https://stackoverflow.com/questions/13920587/struts2-messageresources-in-apache-tiles

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!