struts国际化简单实例

      web技术 2006-3-29 21:36
配置struts环境后,

1. 资源文件的配置:在struts-config.xml文件中增加下面的配置。

<message-resources parameter="resources.application"/>

资源文件的路径:WEB-INF/classes目录下,建立一个resources目录,用来存放资源文件application. properties;

2. 建立资源文件



①在英文资源文件application.properties中加入下面内容:add.worktype = type

②在中文资源文件application_zh.properties中加入下面内容:add.worktype = 类别

在jdk/bin目录下用命令native2ascii 属性文件名 转换后的文件名将application_zh.properties解码:add.worktype = \u7c7b\u578b

3. 显示页面中加入下面代码:

<%@ taglib uri="/tags/struts-bean" prefix="bean" %>

<bean:message key="add.worktype" />

4. 测试

打开IE的"工具"->"Internet选项"菜单,"常规"选项卡可以看到在语言列表,在最上面即为浏览器的默认语言,选择您需要的默认语言,重新启动IE,重启web服务器就ok了。
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commenttime}{commentauthor}

{CommentUrl}
{commentcontent}