首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Struts1上怎么实现国际化

2012-10-24 
Struts1下如何实现国际化Struts1下如何实现国际化1.ApplicationResources属性文件的内容如下:? test.label

Struts1下如何实现国际化

Struts1下如何实现国际化
1.ApplicationResources属性文件的内容如下:
? test.label.title=testTitle
2.在struts-config.xml文件添加如下代码:
? <message-resources key="testResource" parameter="cn/test/ApplicationResources"/>
? testResource为属性文件对应的别名,JSP上用得着。如果有多个属性文件的话,

?? 可以拿来区分。
? cn/test/ApplicationResources:指定属性文件的baseName的路径。
3.JSP中加入标签
? <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
? <bean:message bundle="testResource" key="test.label.title" />?
4.Action如有message的话,可用以下代码读取属性文件的内容

    MessageResources messageResources =MessageResources.getMessageResources(        cn/test/ApplicationResources);    String messageContent = messageResources.getMessage("test.label.title");    

?? 也可以用struts1的方法

?? PropertyMessageResourcesFactory.createResources("cn/test/ApplicationResources");

?

热点排行