1、首先在struts.xml中定義消息資源文件的基本名:
struts.custom.i18n.resources=messages
2、提供各Locale對應(yīng)的資源文件:
message_zh_CN.properties
message_en_US.properties
3、在Action類中根據(jù)key獲取消息內(nèi)容:
方法:getText(“key”); getText("key",new String[]{"content"});
4、在校驗(yàn)配置文件中獲取消息內(nèi)容:
<message key="login.username.empty"></message>
5、在jsp頁面中使用<s:text>標(biāo)簽獲取消息內(nèi)容:
<input type="submit“ value='<s:text name="login.btn.label"></s:text>'/>