struts2 action里set了资源文件的key,页面怎么显示值

struts.properties资源文件:
struts.global.message.success=\u64CD\u4F5C\u6210\u529F
struts.global.message.error=\u64CD\u4F5C\u5931\u8D25

struts2 action:
String globalMessage;//有set/get方法
setGlobalMessage("struts.global.message.success");

jsp页面里怎么显示值,key存在globalMessage里,页面上好像是用getText,具体怎么写

struts.properties是struts启动时自动加载的文件,做配置用的,可能有冲突。

资源文件名最好用globalMessage.properties较好。

步骤:

1 - 在struts.properties文件中加入以下内容:
struts.custom.i18n.resources=globalMessages
或 在struts.xml中加入

注: 你要把struts.properties改成globalMessages.properties

2 在classes目录下放资源文件:
globalMessages_en_US.properties
globalMessages_zh_CN.properties

3 jsp中引用
3.1 简写
/s:text

3.2 指定一个resource bundle

/s:text
/s:i18n

3.3 加参数

robert/s:param
/s:text

[quote]action里执行setGlobalMessage("struts.global.message.success"); ,jsp里怎么显示这个键对应的值[/quote]

Action:
[code="java"]setGlobalMessage(getText("struts.global.message.success")); [/code]

jsp:
[code="java"][/code]