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>
    复制代码

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

  • 相关阅读:
    模拟测试20190806
    替罪羊树学习日记
    [Usaco2015 Jan]Moovie Mooving
    [NOIP2016]愤怒的小鸟
    [BZOJ1556]墓地秘密
    [SDOI2009]学校食堂Dining
    [SCOI2008]奖励关
    [洛谷3930]SAC E#1
    [BZOJ2809/APIO2012]dispatching
    [Usaco2018 Open]Disruption
  • 原文地址:https://www.cnblogs.com/wangsicongde/p/7574274.html
Copyright © 2011-2022 走看看