濮阳杆衣贸易有限公司

主頁 > 知識庫 > ResourceBundle類在jsp中的國際化實現(xiàn)方法

ResourceBundle類在jsp中的國際化實現(xiàn)方法

熱門標簽:南通通訊外呼系統(tǒng)產品介紹 潤滑油銷售電銷機器人 給地圖標注得傭金 電話機器人需要使用網(wǎng)絡嗎 如何看懂地圖標注點 電銷機器人免培訓 自繪地圖標注數(shù)據(jù) 外呼系統(tǒng)使用方法 海外圖書館地圖標注點

今天第一次聽說頁面國際化這個詞,所以查資料,順便做了一個小頁面,做做記錄。

首先是兩個資源文件,分別為msg_en_US.properties和msg_zh_CN.properties

 

顯然中文字符是需要轉換過來的。

這是jsp頁面的代碼

%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

%@page import="java.util.*"%>
!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
html>
 head>
  meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  title>國際化/title>
  style type="text/css">
  div{
   width: 300px;
   text-align: center;
   margin: 0 auto;
  }
  /style>
 /head>
 
 body>
  a href="/International/test.jsp?language=zh" rel="external nofollow" >簡體中文/a>|a href="/International/test.jsp?language=en" rel="external nofollow" >English/a>
  %
   ResourceBundle bund=ResourceBundle.getBundle("msg",request.getLocale());
   String str=request.getParameter("language");
   if(str!=null){
    if("zh".equals(str)){
     bund=ResourceBundle.getBundle("msg",Locale.CHINA);
    }
    else if("en".equals(str)){
     bund=ResourceBundle.getBundle("msg",Locale.US);
    } 
   }
  %>
  div>
   h1>%=bund.getString("inf") %>/h1>
   table>
    tr>
     td>%=bund.getString("name") %>:/td>
     td>input type="text" name="name"/>/td>
    /tr>
    tr>
     td>%=bund.getString("sex") %>:/td>
     td>input type="text" name="sex"/>/td>
    /tr>
    tr>
     td>%=bund.getString("age") %>:/td>
     td>input type="text" name="age"/>/td>
    /tr>
    tr>
     td>%=bund.getString("tel") %>:/td>
     td>input type="text" name="tel"/>/td>
    /tr>
   /table>br/>
   input type="submit" value="%=bund.getString("submit")%>" name="submit"/>
  /div>
 /body>
/html>
 

結果圖

 

以上這篇ResourceBundle類在jsp中的國際化實現(xiàn)方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • 聊聊ResourceBundle和properties讀取配置文件的區(qū)別
  • javaweb 國際化:DateFormat,NumberFormat,MessageFormat,ResourceBundle的使用
  • Java ResourceBundle案例詳解

標簽:樂山 黃石 貸款邀約 廣州 內江 銅川 南京 大連

巨人網(wǎng)絡通訊聲明:本文標題《ResourceBundle類在jsp中的國際化實現(xiàn)方法》,本文關鍵詞  ResourceBundle,類在,jsp,中的,;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《ResourceBundle類在jsp中的國際化實現(xiàn)方法》相關的同類信息!
  • 本頁收集關于ResourceBundle類在jsp中的國際化實現(xiàn)方法的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    遵义县| 丽江市| 灵台县| 若尔盖县| 祁门县| 江华| 西乌珠穆沁旗| 孟村| 嵩明县| 乌拉特后旗| 吉水县| 孟州市| 永新县| 花垣县| 浮山县| 延川县| 易门县| 竹溪县| 特克斯县| 通榆县| 远安县| 尚义县| 马鞍山市| 太谷县| 康乐县| 大悟县| 石泉县| 德江县| 乐清市| 奈曼旗| 元谋县| 衡阳市| 延津县| 成安县| 博乐市| 晋宁县| 和林格尔县| 定襄县| 来宾市| 青铜峡市| 汽车|