免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
struts2國(guó)際化配置文檔
  1. 前提條件:strut2的必須架包已經(jīng)引入,struts2的配置文件全部配置完成
  2. 1.首先創(chuàng)建一個(gè)struts.properties在src目錄下,服務(wù)器啟動(dòng)時(shí)候會(huì)自動(dòng)加載該文件,在這個(gè)文件中寫入struts.custom.i18n.resources=globalMessages,服務(wù)器會(huì)自動(dòng)選擇前綴為globalMessages資源文件。(或者你在你的struts.xml文件中添加<constant name="struts.custom.i18n.resources" value="globalMessages"></constant>服務(wù)器加載struts.xml的時(shí)候會(huì)加載國(guó)際化資源文件);
  3. 2.在src目錄下創(chuàng)建資源文件英文globalMessages_en.properties 中文globalMessages_zh.properties。
  4. globalMessages_en.properties 文件內(nèi)容為homehome=home
  5. globalMessages_zh.properties文件內(nèi)容為 home=\u9996\u9875
  6. 3.在頁(yè)面端獲得資源文件信息。<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
  7. <%@ taglib prefix="s" uri="/struts-tags" %>
  8. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  9. <html>
  10. <head>
  11. <title>My JSP 'test.jsp' starting page</title>
  12. </head>
  13. <body>
  14. <s:text name="home"></s:text>
  15. </body>
  16. </html>
  17. struts2的國(guó)際化分三種情況
  18. 1.前臺(tái)頁(yè)面的國(guó)際化,
  19. 2.Action類中的國(guó)際化,
  20. 3.配置文件的國(guó)際化。
  21. 首先指定全局的國(guó)際化資源文件:
  22. 在配置文件struts.xml中引入
  23. <constant name="struts.custom.i18n.resources" value="message"></constant>(注意位置)
  24. 在struts.properties文件中指定如下一行:
  25. struts.custom.i18n.resources=message
  26. 指定的國(guó)家化資源文件即為
  27. xxx_語(yǔ)言_國(guó)家.properties
  28. message_zh_CN.properties(簡(jiǎn)體中文資源文件)
  29. message_en_US.properties(美國(guó)英語(yǔ)資源文件)
  30. (1).JSP頁(yè)面上的國(guó)際化(使用struts2的<s:text .../>):
  31. <s:i18n name="message">
  32. <s:text name="hello">
  33. <s:param>${username}</s:param>
  34. </s:text>
  35. </s:i18n>
  36. message_en_US.properties文件配置:
  37. hellohello=hello world,{0}
  38. message_zh_CN.properties文件配置:
  39. hello=你好,{0}
  40. (2)表單元素的Label國(guó)際化:
  41. 未國(guó)際化:
  42. <s:textfield name="username" label="username"></s:textfield>
  43. <s:textfield name="password" label="password"></s:textfield>
  44. 國(guó)際化后:
  45. <s:textfield name="username" key="uname"></s:textfield>
  46. <s:textfield name="password" key="pword"></s:textfield>
  47. message_en_US.properties文件,配置:
  48. uname=username
  49. pword=password
  50. message_zh_CN.properties文件,配置:
  51. uname=用戶名
  52. pword=密碼
  53. (3).Action中的國(guó)際化:
  54. 未國(guó)際化:
  55. this.addFieldError("username", "the username error!");
  56. this.addFieldError("password", "the password error!");
  57. 國(guó)際化后:
  58. this.addFieldError("username", "username.error");
  59. this.addFieldError("password", "password.error");
  60. message_en_US.properties文件配置:
  61. username.error = the username error !
  62. password.error = the password error!
  63. message_zh_CN.properties文件配置:
  64. username.error=用戶名錯(cuò)誤!
  65. username.error=密碼錯(cuò)誤!
  66. (4).配置文件中的國(guó)際化:
  67. 以輸入校驗(yàn)的LoginAction-validation.xml為例:
  68. 未國(guó)際化:
  69. <field name="username">
  70. <field-validator type="requiredstring">
  71. <param name="trim">true</param>
  72. <message>username should not be empty!</message>
  73. </field-validator>
  74. <field-validator type="stringlength">
  75. <param name="minLength">6</param>
  76. <param name="maxLength">12</param>
  77. <message>username should be between ${minLength} and ${maxLength}!</message>
  78. </field-validator>
  79. </field>
  80. 國(guó)際化后:
  81. <field name="username">
  82. <field-validator type="requiredstring">
  83. <param name="trim">true</param>
  84. <message key="username.empty !"></message>
  85. </field-validator>
  86. <field-validator type="stringlength">
  87. <param name="minLength">6</param>
  88. <param name="maxLength">12</param>
  89. <message key="username.size"></message>
  90. </field-validator>
  91. </field>
  92. message_en_US.properties文件配置:
  93. username.empty = the username should not be empty !
  94. username.size = the size of username shoule be between 6 and 12 !
  95. message_zh_CN.properties文件配置:
  96. username.empty =用戶名不能為空 !
  97. username.size = 用戶名長(zhǎng)度在6到12 !
  98. 注:message_zh_CN.properties這個(gè)國(guó)際化資源文件不允許包含非西歐字符。
  99. Java提供了一個(gè)工具來(lái)處理該文件中的中文:native2ascii,這個(gè)工具可以在%JAVA_HOME%/bin路勁下找到。
  100. 本文來(lái)自CSDN博客,轉(zhuǎn)載請(qǐng)標(biāo)明出處:http://blog.csdn.net/yaa2004/archive/2009/10/10/4650796.aspx
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
struts2.0國(guó)際化,JSP,action,參數(shù)國(guó)際化
struts處理中文亂碼問(wèn)題
struts 原理與實(shí)踐(5)
"struts中文問(wèn)題","struts國(guó)際化問(wèn)題"的終極解決方案
struts2學(xué)習(xí)筆記(3)——struts2的局部類型轉(zhuǎn)換
Struts2――表單驗(yàn)證
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服