zoukankan      html  css  js  c++  java
  • Struts2--国际化

      Struts对国际化的支持表现在三个地方:

      |-UI标签

      |-验证通知的消息和错误

      |-在action类里面通过getText()方法

       要实现Struts的国际化,首先,需要在struts.xml配置文件中加入如下配置:

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

    然后在src文件夹下写两个用于实现国际化的配置文件

    ·fuwh_zh_CN.properties

    city=u6b22u8fceu8001u5085u6765u5230u4e0au6d77{0}
    name=u5ba2u670d

    ·fuwh_en_US.properties

    city=welcome laofu to shanghai{0}
    name=kefu

    最后编写页面文件

    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <%@ page import="java.util.*" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Insert title here</title>
    </head>
    <body>
        <s:text name="name"></s:text>:
        <s:text name="city">
            <s:param>888888</s:param>
        </s:text>
        <s:property value="getText('name')"/>
    </body>
    </html>

    这样就可以根据本地的语言环境来选择显示的内容了,实现国际化编程

  • 相关阅读:
    python面试题之生成器迭代器
    python之初识函数二
    Python之初识函数一
    Python初识之文件操作
    python初识三
    python初识二
    python初识一
    2.15.5.menuconfig的使用和演示
    2.15.4.内核的配置原理1
    2.15.3.内核配置和编译体验
  • 原文地址:https://www.cnblogs.com/zerotomax/p/6341253.html
Copyright © 2011-2022 走看看