国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

如何使用JSTL標簽做頁面資源國際化

2024-07-21 02:15:03
字體:
來源:轉載
供稿:網友
  1 web應用開發,如何使用jstl 標簽做頁面資源國際化需解決問題描述:1 項目中的文本要實現國際化
  
  2 希望達到按模塊分開編寫國際化資源文件解決方案:
  
  jstl 標簽支持國際化的標簽為
  <fmt:bundle> <fmt:message> <fmt:setbundle><fmt:param>
  <fmt:bundle> 功能:指定消息資源使用的文件
  <fmt:message>功能:顯示消息資源文件中指定key的消息,支持帶參數消息
  <fmt:param> 功能:給帶參數的消息置參數值
  <fmt:setbundle> 功能:設置消息資源文件
  
  一個支持按模塊的多資源文件的國際化例子
  
  步驟1 :定義兩個資源文件,分別為
  resources/iamresources_zh_cn.properties, 內容為
  # 測試使用
  test.common.message = test.common.message1 {0}
  
  resources/usersynresources_zh_cn.properties 內容為
  # 測試使用
  test.usersyn.message = test.usersyn.message1 {0}
  
  步驟2:定義一個公用的jsp文件 includetld.jsp,其內容為
  <%-- struts taglib --%>
  <%@ taglib uri="/web-inf/struts-bean.tld" prefix="bean" %>
  <%@ taglib uri="/web-inf/struts-html.tld" prefix="html" %>
  <%@ taglib uri="/web-inf/struts-logic.tld" prefix="logic" %>
  <%@ taglib uri="/web-inf/struts-nested.tld" prefix="nested" %>
  <%@ taglib uri="/web-inf/struts-template.tld" prefix="template" %>
  <%@ taglib uri="/web-inf/struts-tiles.tld" prefix="tiles" %>
  <%-- jstl taglib --%>
  <%@ taglib prefix="c" uri="/web-inf/c.tld" %>
  <%@ taglib prefix="fmt" uri="/web-inf/fmt.tld" %>
  <%@ taglib prefix="x" uri="/web-inf/x.tld" %>
  <%@ taglib prefix="sql" uri="/web-inf/sql.tld" %>
  
  <%-- set common messageresource --%>
  <fmt:setbundle basename="resources.iamresources" var="commonbundle"/>
  <%-- set usersyn messageresource --%>
  <fmt:setbundle basename="resources.usersynresources" var="usersynbundle"/>
  
  步驟3 : 在需要國際化的jsp頁面使用按如下編寫
  <%@page contenttype="text/html; charset=utf-8"%>
  <%@include file="/includetld.jsp"%>
  
  <fmt:message key="test.common.message" bundle="${commonbundle}">
  <fmt:param value="liaowufeng"/>
  </fmt:message>
  
  <fmt:message key="test.usersyn.message" bundle="${usersynbundle}">
  <fmt:param value="liaowufeng"/>
  </fmt:message>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 马关县| 门头沟区| 天台县| 霍林郭勒市| 吉木萨尔县| 饶平县| 漠河县| 永州市| 兴化市| 邛崃市| 沈丘县| 津南区| 昆山市| 禹州市| 郓城县| 密云县| 马关县| 讷河市| 张家川| 丰城市| 两当县| 五莲县| 蓝田县| 轮台县| 花莲县| 昆山市| 洪洞县| 肇东市| 临西县| 精河县| 宁都县| 开化县| 伊吾县| 泾阳县| 永丰县| 鄢陵县| 兴山县| 保靖县| 武汉市| 潼关县| 东安县|