日期:2014-05-17  浏览次数:20749 次

struts2的配置,如何配properties文件呢
在Struts2中,如何在jsp上取ApplicationResource.properties文件里的值。
如,我创建了一个ApplicationResources.properties文件,里面定义了
label.name = UserName 
label.pwd  = PassWord
可以通过<s:bean name="label.name"/>来取值吗,想在jsp上直接用标签的形式取properties里的值.
Struts1可以在struts-config.xml中加上配置就可以<message-resource ....../>,但struts2怎么配置呢

------解决方案--------------------
使用struts2的国际化特点,然后jap可以借助标签<i18n>表现:
<s:i18n name="myCustomBundle">
   The i18n value for key aaa.bbb.ccc in myCustomBundle is <s:property value="text('aaa.bbb.ccc')" />
</s:i18n>

可以参考官网标签说明
http://struts.apache.org/release/2.3.x/docs/tag-reference.html
------解决方案--------------------
在struts.xml文件中加入<constant name="struts.custom.i18n.resources" value="包名.MessageResouce"/>就可以啦
------解决方案--------------------
看看struts2自带的demo