struts2国际化
第一步、在src文件夹中加入struts.properties文件,内容如下:
struts.custom.i18n.resources=globalMessages
第二步、在src文件夹中加入globalMessages_en_US.properties文件,内容如下:
HelloWorld=Hello World!
第三步、在src文件夹中加入globalMessages_zh_CN.properties文件,内容如下:
HelloWorld=你好,世界!
第四步、中文转码
E:\java\jdk1.5.0\bin>native2ascii -encoding utf-8 globalMessages.properties glob
alMessages_zh_CN.properties
刚开始忘记了转码,老是乱码
第五步、在WebRoot文件夹下加入HelloWorl.jsp文件,内容如下:
<%@ page  contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
    <title>Hello World</title>
</head>
<body>
    <h2><s:text name="HelloWorld"/></h2>
    <h2><s:property value="%{getText('HelloWorld')}"/></h2>
</body>
</html>
第六步、运行


参考资料:
http://www.blogjava.net/max/archive/2006/11/01/78536.html
http://zhidao.baidu.com/question/42176464.html
lunzi   2008-05-26 22:06:39 评论:0   阅读:536   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2008 powered by YuLog