最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2017年07月12日 08:46:43   投稿:jingxian  
下面小編就為大家?guī)硪黄猂esourceBundle類在jsp中的國際化實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

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

首先是兩個資源文件,分別為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)方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

最新評論

凭祥市| 温州市| 筠连县| 北流市| 东安县| 抚松县| 尼勒克县| 农安县| 新疆| 云林县| 和田市| 澄城县| 济宁市| 平原县| 乳山市| 安丘市| 凤山市| 宜昌市| 阳曲县| 施甸县| 四平市| 绥江县| 绍兴县| 阜康市| 仙游县| 三穗县| 突泉县| 常德市| 灵台县| 菏泽市| 庄浪县| 深水埗区| 保山市| 静安区| 安陆市| 中西区| 海城市| 台州市| 桐柏县| 开阳县| 临泽县|