您现在的位置是:首页 >

从零开始的异世界生活雷姆 Struts从零开始四、Struts中的国际化[3]

火烧 2021-12-30 12:39:25 1058
Strut 从零开始四、Strut 中的国际化[3]    创建 trut 的Re ource Bu dle  Strut 配置文件中的元素定义了一个Re ource Bu dle Re ource

Struts从零开始四、Struts中的国际化[3]  

   创建struts的Resource Bundle

  Struts配置文件中的元素定义了一个Resource Bundle Resource Bundle的持久化消息文本存储在资源文件中 其扩展名为 properties 里面存放的都是 键/值

  在struts config xml中对Resource Bundle的配置代码

从零开始的异世界生活雷姆 Struts从零开始四、Struts中的国际化[3]

  表示默认的资源文件应该是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  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码