struts2国际化文件的使用

sturst2国际化资源文件有三种级别从高到低是:类级别(类名_en_US.properties) 、 包级别(package_en_US.properties :package 是固定的写法)、 全局级别(message_en_US.properties)

 使用环境:

1、jsp 中:直接访问jsp,<s:text name="addUser"></s:text>  使用全局的资源文件
    通过action访问jsp, 使用:类级别, 包级别, 全局级别

另一种标签:name=name="com.i18n.I18nAction" com.i18n包下I18nAction_en_US.properties文件

<s:i18n name="com.i18n.I18nAction"><br/>
    <s:text name="test">
        <s:param>aaa</s:param>
    </s:text>
</s:i18n>
   
    2、action中: 继承ActionSupport, this.getText("addUser");  this.getText("test", new String[]{"wan"}) 第二参数填充点位符

猜你喜欢

转载自wanxiaotao12-126-com.iteye.com/blog/1389320