所有的学习我们必须先搭建好Struts2的环境(1、导入对应的jar包,2、web.xml,3、struts.xml)

第一节:国际化简介

国际化(Internationlization),通俗地讲,就是让软件实现对多种语言的支持。

让美国人看到的是英语,让中国人看到的汉语

第二节:Struts2 国际化设置

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

<s:text name=""></s:text> 访问国际化资源

struts.xml

 <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.custom.i18n.resources" value="wishwzp"></constant> </struts>

wishwzp.properties文件内容:(这个是默认的)

  userName=\u7528\u6237\u540d
  password=\u5bc6\u7801
  login=\u767b\u5f55
  welcomeInfo=\u6b22\u8fce{0}

wishwzp_zh_CN.properties文件内容:(这个是中文的)

  userName=\u7528\u6237\u540d
  password=\u5bc6\u7801
  login=\u767b\u5f55
  welcomeInfo=\u6b22\u8fce{0}

wishwzp_en_US.properties文件内容:(这个是英文的)

  userName=userName
  password=password
  login=login
  welcomeInfo=welcome{0}

上面的\u7528\u6237\u540d(“用户名”中文转Unicode为“\u7528\u6237\u540d”)

    \u5bc6\u7801(“密码”中文转Unicode为“\u5bc6\u7801”)

    \u767b\u5f55(“登录”中文转Unicode为“\\u767b\u5f55”)

    \u6b22\u8fce(“欢迎”中文转Unicode为“\u6b22\u8fce”)

都是采用unicode的

Unicode转换工具百度Unicode编码转换 - 站长工具

login.jsp

 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<table>
<tr>
<td><s:text name="userName"></s:text></td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td><s:text name="password"></s:text></td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td>
<input type="button" value="<s:text name='login'></s:text>"/>
</td>
</tr>
</table>
</body>
</html>

welcome.jsp

 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<s:text name="welcomeInfo">
<s:param>Jack</s:param>
</s:text>
</body>
</html>

(六)Struts2 国际化的更多相关文章

  1. struts2国际化

    struts2国际化 1:什么是国际化? 国际化(internationalization)是设计和制造容易适应不同区域要求的产品的一种方式.它要求从产品中抽离所有的与语言,国家/地区和文化相关的元素 ...

  2. 【转】Struts2国际化

    原文章:http://www.cnblogs.com/hellokitty1/p/5083663.html 简单理解     国际化简称i18n,其来源是英文单词 internationalizati ...

  3. struts2系列(四):struts2国际化的多种方式

    一.struts2国际化原理 根据不同的Locale读取不同的文本. 例如有两个资源文件: 第一个:message_zh_CN.properties 第二个:message_en_US.propert ...

  4. 菜鸟学SSH(三)——Struts2国际化自动检测浏览器语言版

    前几天发了一篇Struts国际化的博客——<菜鸟学习SSH(二)——Struts2国际化手动切换版>,有网友提了一个意见,见下图: 于是就有了下面修改的版本: web.xml <?x ...

  5. struts2学习(10)struts2国际化

    一.国际化简介: 二.struts2国际化设置: struts.xml: <?xml version="1.0" encoding="UTF-8" ?&g ...

  6. Struts2国际化-getText()方法

    转自https://blog.csdn.net/qq_43560838/article/details/83747604 一:简单理解 国际化简称i18n,其来源是英文单词 international ...

  7. [JavaWeb基础] 016.Struts2 国际化配置

    如果一个软件想要让其受众是全球或者是几个国家的人,那么这个软件就需要支持多种语言,那么我们就需要软件的国际化去对一些文字信息进行国际化处理.web也一样,当外国人打开我们的网站,要是看到满屏幕的中文, ...

  8. struts2 国际化

    国际化概述: 软件国际化:一个软件根据来访者地区不同,显示不同语言. 国际化: * 必须有一组资源包: * 一组属性文件命名: 基本名称_语言(小写)_国家(大写).properties * 如:me ...

  9. struts2总结六: Struts2的拦截器

    一.Struts2的系统结构图

随机推荐

  1. 一个PHP书单 -摘自网络

    # PHP <PHP程序设计>(第2版) –PHP语法和入门最好的书 <PHP5权威编程> –PHP入门后升级书 <深入PHP:面向对象.模式与实践>(第3版) – ...

  2. Yii 安装二维码扩展Qrcode

    比如要添加 https://github.com/2amigos/yii2-qrcode-helper 生成二维码的 这个扩展第一种方法 :    1.打开根目录的composer.json, 在re ...

  3. FairScheduler的任务调度机制——assignTasks(续)

    上一篇文章浅析了FairScheduler的assignTasks()方法,介绍了FairScheduler任务调度的原理.略过了最后一步通过JobScheduler获取Task时调用JobInPro ...

  4. The server quit without updating PID file (mysql.pid)一次意外mysql停止运行备忘录

    [root@iZ23tsvd9h4Z ~]# service mysqld status ERROR! MySQL (Percona Server) is not running, but lock ...

  5. ECMAScript和JavaScript的联系

    ECMAScript是一种规范,一种标准.类似于编程语言的接口,定义好一套规范后,各大浏览器厂商遵循规范各自实现之,同时,也做了一些扩展,这些扩展就是规范里面没有的. JavaScript是一种实现, ...

  6. BABOK - 企业分析(Enterprise Analysis)

    BABOK - 企业分析(Enterprise Analysis)概要 发表于2013年10月9日由周金根 描述 企业分析描述我们如何捕捉.提炼并明晰业务需要,并定义一个可能实现这些业务需要的一个方案 ...

  7. WPF button 圆角制作

    将以下节点复制到app.xaml的<Application.Resources>节点下 <Style TargetType="{x:Type Button}"&g ...

  8. android82 启动Actvity和Activity的生命周期

    package com.itheima.jump; import android.net.Uri; import android.os.Bundle; import android.app.Activ ...

  9. Performance Tuning of Spring/Hibernate Applications---reference

    http://java.dzone.com/articles/performance-tuning For most typical Spring/Hibernate enterprise appli ...

  10. display_errors & error_reporting(php调试安全)

    这两个选项对应的值即都可以在php.ini文件中设置,也都可以在php代码中使用相应的函数来设置. 在php.ini文件中的设置如下: