資源文件中的內(nèi)容如下:
Welcome={0},歡迎來到中國{1}
1在JSP頁面中輸出帶有占位符的國際化信息
<s:text name=”welcome”>
<s:param><s:property value=”realname”/></s:param>
<s:param>學(xué)習(xí)</s:param>
</s:text>
example:
<s:text name="welcome">
<s:param>liming</s:param>
<s:param>study</s:param>
</s:text> <br>
2
在Action類中獲取帶占位符的國際化信息,可以使用getText(String key , String[]args )
或getText(String aTextName,List args)
example:
ActionContext.getContext().put("message", this.getText("welcome",new String[]{"liming","study"}));