您的位置:首页 > 编程语言 > Java开发

struts根据浏览器自动选择文字语言(国际化)

2010-07-13 12:53 393 查看
1.建立与ApplicationResources.properties文件相关联的ApplicationResources_zh_CN.properties和ApplicationResources_en_US.properties等语言配置资源文件,如图1。(上传出错)

在properties文件中写入key和value,如zh_CN如下(/u7528为中文的ASCII码)

username=/u7528/u6237
password=/u5BC6/u7801
email=/u90AE/u7BB1
phone=/u7535/u8BDD
button.submit=/u63D0/u4EA4
button.reset=/u91CD/u7F6E


2.在需要使用文字的位置使用如下代码即可显示出根据系统语言自动选择的文字

<html:form action="/user.do" method="post">
<bean:message key="uname"/> : <html:text property="uname"/><html:errors property="uname"/><br/>
<bean:message key="upass"/> : <html:password property="upass"/><html:errors property="upass"/><br/>
<bean:message key="rpass"/> : <html:password property="rpass"/><html:errors property="rpass"/><br/>
<bean:message key="email"/> : <html:text property="email"/><html:errors property="email"/><br/>
<html:submit><bean:message key="button.submit"/></html:submit>
<html:cancel><bean:message key="button.reset"/></html:cancel>
</html:form>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐