struts2框架開發國際化筆記

國際化

(1)配置struts.xml
<constant name="struts.cumtom.i18n.resources" value="baseMessage"/>
(2)國際化使用配置文件實現。配置文件的類型有三種:全局配置文件,包範圍,Action範圍
全局:baseMessage_en_US.properties
包:package_en_US.properties
Action:Action類名_en_US.properties
最好都寫一個缺省配置文件:baseMessage.properties,package.properties,Action類名.properties
(3)國際化顯示方式
jsp頁面:<%@ taglib prefix="s" uri="/struts-tags" %>
         <s:text name="key值"/>或
  <s:text name="key值"><s:param>content</s:param></s:text>
Action類:繼承ActionSupport類後,使用this.getText("key值");
    帶參數:this.getText(String key,String 參數1);
(4)特別指明:
在配置文件中,value的值可以帶jsp表達式,如${getText(fileName)}is required

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章