struts2之国际化(i18n)
来源:互联网 发布:otg软件下载 编辑:程序博客网 时间:2024/05/14 08:22
(一)在struts.xml中配置<constant name="struts.custom.i18n.resources" value="bbs2009"></constant>其中Value=“bbs2009”表示资源文件的前缀。
统一管理资源文件:app_en_US.properties app_zh_CN.properties
其中:中文要转换为UTF-8格式的ASCII编码才可以;
我们可以使用插件来自动转换:PropertiesEditor插件
使用方法:先下载解压,将其中的feature plugin 文件覆盖中myeclipse中的 eclipse目录里即可
(二)import java.util.Locale;
import java.util.ResourceBundle;
public class Test {
public static void main(String[] args) {
ResourceBundle res = ResourceBundle.getBundle("app", Locale.CHINA);
System.out.println(res.getString("welcome.msg" ));
}
}
(三)app_en_US.properties文件中的内容如下:
login.username=username:
login.password=password:
login.login=login
(四)登陆界面:实现中英文的转换:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>管理员登录</title>
</head>
<body>
<form action="admin/Login-login" method="post">
<s:property value="getText('login.username')"/><input name="username" />
<s:property value="getText('login.password')"/><input name="password" type="password" />
<input type="submit" value="<s:property value="getText('login.login')"/>" />
</form>
<s:debug></s:debug>
<a href="admin/lang?request_locale=en_US">en</a>
<a href="admin/lang?request_locale=zh_CN">cn</a>
</body>
</html>
其中:参数格式:request_locale=en_US 必须以这种形式传递
- struts2之国际化(i18n)
- Struts2 2.0 国际化(i18n)
- Struts2笔记六之i18n国际化
- Struts2中的I18N(国际化)处理
- Java Struts2 本地化/国际化(i18n)浅析
- Struts2中的I18N(国际化)处理
- Struts2中的I18N(国际化)处理
- struts2 国际化 i18n
- struts2 i18n国际化问题
- struts2的国际化i18n
- Struts2国际化详解 i18n
- Struts2国际化标签 i18n
- struts2 国际化 I18N
- struts2中I18N国际化
- Struts2.0 (开发之四)--(i18n)国际化--CTO
- struts2的国际化(i18n)操作
- struts2的国际化 i18n 总结
- struts2 学习总结 ---- i18n国际化
- 杰卡德相似系数
- 2631: tree LCT第二题
- windows下在控制台下 mysql的一些简单的控制语句
- mysql备份还原,在win7系统上可以,在winservice2008中不能成功备份大数据。
- Coursera机器学习 Week7 笔记
- struts2之国际化(i18n)
- 全在其中
- 版本管理器的搭建
- 英语偏旁部首
- C++中的也能使用正则表达式
- 2109找女朋友(快排递归算法与非递归算法)
- List<?>和List<T>的区别?以及List 和List<Object>的关系
- 从运维工程师的角度谈谈如何学习Linux
- NGUI控件---Slider滑动条