Struts2应用开发详解-17、对国际化的支持
Struts2应用开发详解--17、对国际化的支持。
国际化的支持建立在系统语言环境参数基础上,Struts框架会根据语音环境自动选择国际化语言显示。具体配置步骤如下:
一、建立对应语言环境的.properties文件如:
test_zh_CN.properties //中国大陆
test_en_US.properties //美国
二、配置struts.xml文件
<constant name="struts.custom.i18n.resources" value="test"></constant>
三、访问方式
1、JSP中访问
<s:text name="id">,id配置文件中的“key”
2、Action中访问
Action访问必须继承ActionSupport类,使用getText(String key),得到国际化信息。其中参数key对应于配置文件中的key。
3、在表达标签中引用访问。
<s:textfield name="info" key="id" />