从零开始的异世界生活雷姆 Struts从零开始四、Struts中的国际化[3]
Struts从零开始四、Struts中的国际化[3]
创建struts的Resource Bundle
Struts配置文件中的元素定义了一个Resource Bundle Resource Bundle的持久化消息文本存储在资源文件中 其扩展名为 properties 里面存放的都是 键/值
在struts config xml中对Resource Bundle的配置代码
![从零开始的异世界生活雷姆 Struts从零开始四、Struts中的国际化[3]](http://img.zhputi.com/uploads/13a8/13a81bd420a66a70fe9c0999544b109224563.jpg)
表示默认的资源文件应该是applicationResources properties 存放在应用程序的根目录 WEB INF目录 classes目录下 如果应用程序需要支持中文用户 要在相同目录下创建一个包涵中文消息的资源文件 文件名必须为applicationResource_zh_CN properties
修改login jsp页面
<:form action= login do method= post >
<bean:message key= label username />
<:text property= username /><:errors property= username />
<br />
<bean:message key= label password />
<:text property= userpass /><:errors property= userpass />
<br>
<input type= submit name= Submit value= <bean:message key= button submit /> >
<input type= reset value= <bean:message key= button reset /> >
</:form>
<bean:message/>:用于访问web应用资源的bean标签 显示Resource Boundle中的内容
运行程序
)如果你的浏览器默认设置为中文 你键入地址 将看到的页面如下
)把你的浏览器的设置为英文 然后刷新页面 如下图
lishixinzhi/Article/program/Java/ky/201311/29117