zoukankan      html  css  js  c++  java
  • JavaWeb学习:Struts2国际化

    全局的国际化

    一、提供一组资源:

      资源的命名:基本名称_语言_国家.properties

      放在src下

        message_zh_CN.properties

    name=项目
    login.username=用户名不能为空
    welcome={0},欢迎

        message_en_US.properties

    name=project
    login.username=UserName Not Null
    welcome={0},welcome

      struts.xml设置常量struts.custom.i18n.resources的value=资源的基本名称:

     <constant name="struts.custom.i18n.resources" value="message" />

      在Action类中

    String name = getText("name");
    //占位符
    String name = getText("welcome",new String[]{"lisi"});

      在jsp中

    <s:text name="name" />
    <!-- 占位符 -->
    <s:text name="welcome" >
        <s:param>zhangsan</s:param>
    </s:text>

      在配置文件(指校验的XML文件)中

    <validators>
        <field name="name">
            <field-validator type="requiredstring">
                <message key="login.username"></message> 
            </field-validator> 
        </field> 
    </validators>
  • 相关阅读:
    python3文件操作
    python3复习
    python3集合
    python购物车
    python小知识点总结
    python-review01
    python字典
    04day->python列表和元祖
    python字符串操作
    《令人拍案称奇的Mask RCNN》
  • 原文地址:https://www.cnblogs.com/WarBlog/p/14081523.html
Copyright © 2011-2022 走看看