zoukankan      html  css  js  c++  java
  • Java——Struts2 之国际化 struts.custom.i18n.resources=globalMessages

    1.在src下 建立 struts.properties 文件,内容为:struts.custom.i18n.resources=globalMessages

      struts.custom.i18n.resources是固定写法,在struts2核心包中可以找到。

    2.在src下 建立globalMessages_en.properties (代表英文国际化)、建立globalMessages_zh.properties(中文国际化)文件

      globalMessages_en.properties内容为:(命名=你想要显示的名字)

      username=username
      password=password

      globalMessages_zh.properties内容为:(命名=你想要显示的名字)

      username=u7528u6237u540D
      password=u5BC6u7801

    建议:在中文的文件中,直接在Properties页面中点击Add进行添加,不然直接写的话,系统不认识,报错。

    3.jsp文件:

    <h1><font color="red">Input UserInfo</font></h1>
        <s:form action="userlogin">
            <s:textfield name="user.username" label="%{getText('username')}"></s:textfield>
            <s:textfield name="user.password" label="%{getText('password')}"></s:textfield>
            <s:submit label="submit"></s:submit>
        </s:form>

      label="%{getText('username')}" 就是获取国际化文件中所配置的内容。

    4.结果:

    逃避不一定躲得过,面对不一定最难过
  • 相关阅读:
    腾讯游戏是如何使用Docker的
    为Elasticsearch添加中文分词,对比分词器效果
    13个对web设计师有用的JavaScript插件
    七牛是如何搞定每天500亿条日志的
    七牛李道兵谈“架构坏味道”
    接口的解释
    数组
    Div Span
    dl dt dd
    @Razor解析器
  • 原文地址:https://www.cnblogs.com/yangzhenlong/p/3511528.html
Copyright © 2011-2022 走看看