⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ebank5.html

📁 j2eePDF格式的电子书
💻 HTML
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />    <meta http-equiv="Content-Style-Type" content="text/css" />    <title>Internationalization</title>    <link rel="StyleSheet" href="document.css" type="text/css" media="all" />    <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" />    <link rel="Table of Contents" href="J2EETutorialTOC.html" />    <link rel="Previous" href="Ebank4.html" />    <link rel="Next" href="Ebank6.html" />    <link rel="Index" href="J2EETutorialIX.html" />  </head>  <body>    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="Ebank4.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="Ebank6.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <blockquote><a name="wp80202"> </a><h2 class="pHeading1">Internationalization</h2><a name="wp80205"> </a><p class="pBody">The J2EE application client and Web client distributed with the Duke's Bank application are internationalized. All strings that appear in the user interfaces are retrieved from resource bundles. The administration client uses resource bundles named <code class="cCode">AdminMessages_*.properties</code>. The Web client uses resource bundles named <code class="cCode">WebMessages_*.properties</code>. Both clients are distributed with English and Spanish resource bundles.</p><a name="wp80206"> </a><p class="pBody">The application client retrieves locale information from the command line. For example, to use the Spanish resource bundle, invoke the application like this: </p><div class="pPreformattedRelative"><pre class="pPreformattedRelative"><code class="cCode">appclient -client DukesBankAppClient.jar es</code><a name="wp80207"> </a></pre></div><a name="wp80208"> </a><p class="pBody">The administration client class <code class="cCode">BankAdmin</code> creates a <code class="cCode">ResourceBundle</code> with a locale created from the command-line arguments:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">//Constructorpublic BankAdmin(Locale currentLocale) {&nbsp;&nbsp;//Internationalization setup&nbsp;&nbsp;messages = ResourceBundle.getBundle(&quot;AdminMessages&quot;,&nbsp;&nbsp;&nbsp;&nbsp;currentLocale);<a name="wp80209"> </a></pre></div><a name="wp80210"> </a><p class="pBody">The Web client <code class="cCode">Dispatcher</code> component retrieves the locale (set by a browser language preference) from the request, opens the resource bundle, and then saves the bundle as a session attribute:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">ResourceBundle messages = (ResourceBundle)session.&nbsp;&nbsp;getAttribute(&quot;messages&quot;);&nbsp;&nbsp;if (messages == null) {&nbsp;&nbsp;&nbsp;&nbsp;Locale locale=request.getLocale();&nbsp;&nbsp;&nbsp;&nbsp;messages = ResourceBundle.getBundle(&quot;WebMessages&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;locale); &nbsp;&nbsp;&nbsp;&nbsp;session.setAttribute(&quot;messages&quot;, messages);&nbsp;&nbsp;}<a name="wp80211"> </a></pre></div><a name="wp80212"> </a><p class="pBody">The Web client's JavaBeans components access localized messages using <code class="cCode">messages.getString(&quot;</code><code class="cVariable">key</code><code class="cCode">&quot;);</code>. </p><a name="wp82895"> </a><p class="pBody">The Web client's JSP pages use the JSTL <code class="cCode">fmt:message</code> tags to retrieve localized messages. You set the localization context of the JSTL <code class="cCode">fmt</code> tag library as a context parameter when you package the Web client with <code class="cCode">deploytool</code>. </p><a name="wp82837"> </a><p class="pBody">For example, here is how <code class="cCode"><a  href="../bank/web/accountHist.txt" target="_blank">accountHist.jsp</a></code> generates the headings for the transactions table:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">&lt;td&gt;&lt;center&gt;&lt;b&gt;&lt;fmt:message &nbsp;&nbsp;key=&quot;TxDate&quot;/&gt;&lt;/b&gt;&lt;/center&gt;&lt;/td&gt;&lt;td&gt;&lt;center&gt;&lt;b&gt;&lt;fmt:message&nbsp;&nbsp;key=&quot;TxDescription&quot;/&gt;&lt;/center&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;center&gt;&lt;b&gt;&lt;fmt:message &nbsp;&nbsp;key=&quot;TxAmount&quot;/&gt;&lt;/b&gt;&lt;/center&gt;&lt;/td&gt;&lt;td&gt;&lt;center&gt;&lt;b&gt;&lt;fmt:message&nbsp;&nbsp;key=&quot;TxRunningBalance&quot;/&gt;&lt;/b&gt;&lt;/center&gt;&lt;/td&gt;<a name="wp82811"> </a></pre></div>    </blockquote>   <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="Ebank4.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="Ebank6.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"><p><font size="-1">All of the material in <em>The J2EE(TM) 1.4 Tutorial</em> is <a href="J2EETutorialFront2.html">copyright</a>-protected and may not be published in other workswithout express written permission from Sun Microsystems.</font>  </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -