﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-zjhgx</title><link>http://www.blogjava.net/zjhgx/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 28 Apr 2026 18:57:32 GMT</lastBuildDate><pubDate>Tue, 28 Apr 2026 18:57:32 GMT</pubDate><ttl>60</ttl><item><title>在Struts 2.0中国际化(i18n)您的应用程序(转自http://www.blogjava.net/max/archive/2006/11/01/78536.html)</title><link>http://www.blogjava.net/zjhgx/archive/2009/08/25/292516.html</link><dc:creator>david hu</dc:creator><author>david hu</author><pubDate>Tue, 25 Aug 2009 06:56:00 GMT</pubDate><guid>http://www.blogjava.net/zjhgx/archive/2009/08/25/292516.html</guid><wfw:comment>http://www.blogjava.net/zjhgx/comments/292516.html</wfw:comment><comments>http://www.blogjava.net/zjhgx/archive/2009/08/25/292516.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zjhgx/comments/commentRss/292516.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zjhgx/services/trackbacks/292516.html</trackback:ping><description><![CDATA[
		<p>国际化是商业系统中不可或缺的一部分，所以无论您学习的是什么Web框架，它都是必须掌握的技能。</p>
		<p>其实，Struts 1.x在此部分已经做得相当不错了。它极大地简化了我们程序员在做国际化时所需的工作，例如，如果您要输出一条国际化的信息，只需在代码包中加入 FILE-NAME_xx_XX.properties（其中FILE-NAME为默认资源文件的文件名），然后在struts-config.xml中指明其路径，再在页面用&lt;bean:message&gt;标志输出即可。 </p>
		<p>不过，所谓“没有最好，只有更好”。Struts 2.0并没有在这部分止步，而是在原有的简单易用的基础上，将其做得更灵活、更强大。</p>
		<h2>国际化Hello World</h2>
		<p>下面让我们看一个例子——HelloWorld。这个例子演示如何根据用户浏览器的设置输出相应的HelloWorld。</p>
		<ol>
				<li>在Eclipse创建工程配置开发和运行环境（如果对这个步骤有问题，可以参考我早前的文章《<a class="entrylistItemTitle" id="A1" href="/max/archive/2006/10/10/74353.html">为Struts 2.0做好准备</a>》）。 <br /></li>
				<li>在src文件夹中加入struts.properties文件，内容如下： <br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0)">struts.custom.i18n.resources</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">globalMessages</span></div><center><table style="BORDER-RIGHT: rgb(240,192,0) 1px solid; BORDER-TOP: rgb(240,192,0) 1px solid; MARGIN-TOP: 8px; MARGIN-BOTTOM: 8px; BORDER-LEFT: rgb(240,192,0) 1px solid; BORDER-BOTTOM: rgb(240,192,0) 1px solid; BACKGROUND-COLOR: rgb(255,255,206); TEXT-ALIGN: left" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td style="PADDING-RIGHT: 4px; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px"><img src="http://cwiki.apache.org/confluence/images/icons/emoticons/lightbulb_on.gif" /></td><td style="PADDING-RIGHT: 4px; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px; FONT-FAMILY: 华文仿宋">Struts 2.0有两个配置文件，struts.xml和struts.properties都是放在WEB-INF/classes/下。 
<ul><li>struts.xml用于应用程序相关的配置 </li><li>struts.properties用于Struts 2.0的运行时（Runtime）的配置</li></ul></td></tr></tbody></table></center></li>
				<li>在src文件夹中加入globalMessages_en_US.properties文件，内容如下：<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; MARGIN-BOTTOM: 8px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0)">HelloWorld</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">Hello World!</span></div></li>
				<li>在src文件夹中加入globalMessages_zh_CN.properties文件，内容如下：<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0)">HelloWorld</span><span style="COLOR: rgb(0,0,0)">=你</span><span style="COLOR: rgb(0,0,0)">好，世界！</span></div><table style="BORDER-RIGHT: rgb(240,192,0) 1px solid; BORDER-TOP: rgb(240,192,0) 1px solid; MARGIN-TOP: 8px; MARGIN-BOTTOM: 8px; BORDER-LEFT: rgb(240,192,0) 1px solid; BORDER-BOTTOM: rgb(240,192,0) 1px solid; BACKGROUND-COLOR: rgb(255,255,206); TEXT-ALIGN: left" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td style="PADDING-RIGHT: 4px; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px"><img src="http://cwiki.apache.org/confluence/images/icons/emoticons/lightbulb_on.gif" /></td><td style="PADDING-RIGHT: 4px; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px; FONT-FAMILY: 华文仿宋">在此想和大家分享一个不错的编写properties文件的Eclipse插件（plugin），有了它我们在编辑一些简体中文、繁体中文等Unicode 文本时，就不必再使用native2ascii编码了。您可以通过Eclipse中的软件升级（Software Update）安装此插件，步骤如下：<br /><div style="PADDING-RIGHT: 36px; PADDING-LEFT: 36px">1、展开Eclipse的Help菜单，将鼠标移到Software Update子项，在出现的子菜单中点击Find and Install；<br />2、在Install/Update对话框中选择Search for new features to install，点击Next；<br />3、在Install对话框中点击New Remote Site；<br />4、在New Update Site对话框的Name填入“PropEdit”或其它任意非空字符串，在URL中填入http://propedit.sourceforge.jp/eclipse/updates/；<br />5、在Site to include to search列表中，除上一步加入的site外的其它选项去掉，点击Finsih；<br />6、在弹出的Updates对话框中的Select the features to install列表中将所有结尾为“3.1.x”的选项去掉（适用于Eclipse 3.2版本的朋友）；<br />7、点击Finish关闭对话框；<br />8、在下载后，同意安装，再按提示重启Eclipse，在工具条看到形似vi的按钮表示安装成功，插件可用。此时，Eclpise中所有properties文件的文件名前有绿色的P的图标作为标识。 </div></td></tr></tbody></table></li>
				<li>在WebContent文件夹下加入HelloWorl.jsp文件，内容如下：<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; MARGIN-BOTTOM: 8px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)">&lt;%</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">@ page  contentType</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">text/html; charset=UTF-8</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)">%&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)">&lt;%</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">@taglib prefix</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">s</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> uri</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">/struts-tags</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"></span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)">%&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">html</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">head</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br />    </span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">title</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)">Hello World</span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">title</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">head</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">body</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br />    </span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">h2</span><span style="COLOR: rgb(0,0,255)">&gt;&lt;</span><span style="COLOR: rgb(128,0,0)">s:text </span><span style="COLOR: rgb(255,0,0)">name</span><span style="COLOR: rgb(0,0,255)">="HelloWorld"</span><span style="COLOR: rgb(255,0,0)"></span><span style="COLOR: rgb(0,0,255)">/&gt;&lt;/</span><span style="COLOR: rgb(128,0,0)">h2</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br />    </span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">h2</span><span style="COLOR: rgb(0,0,255)">&gt;&lt;</span><span style="COLOR: rgb(128,0,0)">s:property </span><span style="COLOR: rgb(255,0,0)">value</span><span style="COLOR: rgb(0,0,255)">="%{getText('HelloWorld')}"</span><span style="COLOR: rgb(255,0,0)"></span><span style="COLOR: rgb(0,0,255)">/&gt;&lt;/</span><span style="COLOR: rgb(128,0,0)">h2</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">body</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">html</span><span style="COLOR: rgb(0,0,255)">&gt;</span></div></li>
				<li>发布运行应用程序，在浏览器地址栏中输入<a href="http://localhost:8080/Struts2_i18n/HelloWorld.jsp">http://localhost:8080/Struts2_i18n/HelloWorld.jsp</a> ，出现图1所示页面。<br /><img alt="图1 中文输出" src="http://www.blogjava.net/images/blogjava_net/max/16758/r_imag2.gif" /><br /><span style="FONT-SIZE: smaller; MARGIN-BOTTOM: 8px; FONT-STYLE: italic">图1 中文输出</span></li>
				<li>将浏览器的默认语言改为“英语（美国）”，刷新页面，出现图2所示页面。<br /><img alt="图2 英文输出" src="http://www.blogjava.net/images/blogjava_net/max/16758/r_imag1.gif" /><br /><span style="FONT-SIZE: smaller; MARGIN-BOTTOM: 8px; FONT-STYLE: italic">图2 英文输出</span></li>
		</ol>上面的例子的做法，与Struts 1.x的做法相似，似乎并不能体现Struts 2.0的优势。不过，我在上面的例子用了两种方法来显示国际化字符串，其输出是相同的。其实，这就是Struts 2.0的一个优势，因为它默认支持EL，所示我们可以用getText方法来简洁地取得国际化字符串。另外更普遍的情况——在使用UI表单标志时，getText可以用来设置label属性，例如：<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">s:textfield </span><span style="COLOR: rgb(255,0,0)">name</span><span style="COLOR: rgb(0,0,255)">="name"</span><span style="COLOR: rgb(255,0,0)"> label</span><span style="COLOR: rgb(0,0,255)">="%{getText('UserName')}"</span><span style="COLOR: rgb(255,0,0)"></span><span style="COLOR: rgb(0,0,255)">/&gt;</span></div><h2>资源文件查找顺序</h2><p>之所以说Struts 2.0的国际化更灵活是因为它可以能根据不同需要配置和获取资源（properties）文件。在Struts 2.0中有下面几种方法：</p><ol><li>使用全局的资源文件，方法如上例所示。这适用于遍布于整个应用程序的国际化字符串，它们在不同的包（package）中被引用，如一些比较共用的出错提示； </li><li>使用包范围内的资源文件。做法是在包的根目录下新建名的package.properties和package_xx_XX.properties文件。这就适用于在包中不同类访问的资源； </li><li>使用Action范围的资源文件。做法为Action的包下新建文件名（除文件扩展名外）与Action类名同样的资源文件。它只能在该Action中访问。如此一来，我们就可以在不同的Action里使用相同的properties名表示不同的值。例如，在ActonOne中 title为“动作一”，而同样用title在ActionTwo表示“动作二”，节省一些命名工夫； </li><li>使用&lt;s:i18n&gt;标志访问特定路径的properties文件。使用方法请参考我早前的文章《<a class="entrylistItemTitle" id="CategoryEntryList1_EntryStoryList_Entries_ctl02_TitleUrl" href="/max/archive/2006/10/18/75857.html">常用的Struts 2.0的标志（Tag）介绍</a>》。在您使用这一方法时，请注意&lt;s:i18n&gt;标志的范围。在&lt;s:i18n name="xxxxx"&gt;到&lt;/s:i18n&gt;之间，所有的国际化字符串都会在名为xxxxx资源文件查找，如果找不到，Struts 2.0就会输出默认值（国际化字符串的名字）。</li></ol><p>上面我列举了四种配置和访问资源的方法，它们的范围分别是从大到小，而Struts 2.0在查找国际化字符串所遵循的是特定的顺序，如图3所示：</p><img alt="图3 资源文件查找顺序图" src="http://www.blogjava.net/images/blogjava_net/max/16758/o_Search.jpg" /><br /><span style="FONT-SIZE: smaller; MARGIN-BOTTOM: 8px; FONT-STYLE: italic">图3 资源文件查找顺序图</span><p>假设我们在某个ChildAction中调用了getText("user.title")，Struts 2.0的将会执行以下的操作： </p><ol><li>查找ChildAction_xx_XX.properties文件或ChildAction.properties； </li><li>查找ChildAction实现的接口，查找与接口同名的资源文件MyInterface.properties； </li><li>查找ChildAction的父类ParentAction的properties文件，文件名为ParentAction.properties； </li><li>判断当前ChildAction是否实现接口ModelDriven。如果是，调用getModel()获得对象，查找与其同名的资源文件； </li><li>查找当前包下的package.properties文件； </li><li>查找当前包的父包，直到最顶层包； </li><li>在值栈（Value Stack）中，查找名为user的属性，转到user类型同名的资源文件，查找键为title的资源; </li><li>查找在struts.properties配置的默认的资源文件，参考例1; </li><ol><li value="9">输出user.title。</li></ol><li><h2>参数化国际化字符串</h2><p>许多情况下，我们都需要在动行时（runtime）为国际化字符插入一些参数，例如在输入验证提示信息的时候。在Struts 2.0中，我们通过以下两种方法做到这点：</p><ol><li>在资源文件的国际化字符串中使用OGNL，格式为${表达式}，例如：<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; MARGIN-BOTTOM: 8px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0)">validation.require</span><span style="COLOR: rgb(0,0,0)">=</span><span style="MARGIN-BOTTOM: 8px; COLOR: rgb(0,0,0)">${getText(fileName)} is required</span></div></li><li>使用<a href="http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/text/MessageFormat.html">java.text.MessageFormat</a>中的字符串格式，格式为{ 参数序号（从0开始）, 格式类形（number | date | time | choice）, 格式样式}，例如：<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0)">validation.between</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">Date must between {</span><span style="COLOR: rgb(0,0,0)">0</span><span style="COLOR: rgb(0,0,0)">,</span><span style="COLOR: rgb(0,0,0)"> date, short} and {</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)">,</span><span style="COLOR: rgb(0,0,0)"> date, short}</span></div></li></ol>在显示这些国际化字符时，同样有两种方法设置参数的值：<br /><ol><li>使用标志的value0、value1...valueN的属性，如：<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; MARGIN-BOTTOM: 8px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">s:text </span><span style="COLOR: rgb(255,0,0)">name</span><span style="COLOR: rgb(0,0,255)">="validation.required"</span><span style="COLOR: rgb(255,0,0)"> value0</span><span style="COLOR: rgb(0,0,255)">="User Name"</span><span style="COLOR: rgb(255,0,0)"></span><span style="COLOR: rgb(0,0,255)">/&gt;</span></div></li><li>使用param子元素，这些param将按先后顺序，代入到国际化字符串的参数中，例如：<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">s:text </span><span style="COLOR: rgb(255,0,0)">name</span><span style="COLOR: rgb(0,0,255)">="validation.required"</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br />   </span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">s:param </span><span style="COLOR: rgb(255,0,0)">value</span><span style="COLOR: rgb(0,0,255)">="User Name"</span><span style="COLOR: rgb(255,0,0)"></span><span style="COLOR: rgb(0,0,255)">/&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">s:text</span><span style="COLOR: rgb(0,0,255)">&gt;</span></div></li></ol><h2>让用户方便地选择语言</h2><p>开发国际化的应用程序时，有一个功能是必不可少的——让用户快捷地选择或切换语言。在Struts 2.0中，通过ActionContext.getContext().setLocale(Locale arg)可以设置用户的默认语言。不过，由于这是一个比较普遍的应用场景（Scenario），所以Struts 2.0为您提供了一个名i18n的拦截器（Interceptor），并在默认情况下将其注册到拦截器链（Interceptor chain）中。它的原理为在执行Action方法前，i18n拦截器查找请求中的一个名为"request_locale"的参数。如果其存在，拦截器就将其作为参数实例化Locale对象，并将其设为用户默认的区域（Locale），最后，将此Locale对象保存在session的名为 “WW_TRANS_I18N_LOCALE”的属性中。</p><p>下面，我将提供一完整示例演示它的使用方法。</p><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: rgb(0,0,255)">package</span><span style="COLOR: rgb(0,0,0)"> tutorial;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> java.util.Hashtable;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> java.util.Locale;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> java.util.Map;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img id="Codehighlighter1_116_345_Open_Image" onclick="this.style.display='none'; Codehighlighter1_116_345_Open_Text.style.display='none'; Codehighlighter1_116_345_Closed_Image.style.display='inline'; Codehighlighter1_116_345_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_116_345_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_116_345_Closed_Text.style.display='none'; Codehighlighter1_116_345_Open_Image.style.display='inline'; Codehighlighter1_116_345_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">class</span><span style="COLOR: rgb(0,0,0)"> Locales </span><span id="Codehighlighter1_116_345_Closed_Text" style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)"><img src="http://www.blogjava.net/images/dot.gif" /></span><span id="Codehighlighter1_116_345_Open_Text"><span style="COLOR: rgb(0,0,0)">{<br /><img id="Codehighlighter1_159_343_Open_Image" onclick="this.style.display='none'; Codehighlighter1_159_343_Open_Text.style.display='none'; Codehighlighter1_159_343_Closed_Image.style.display='inline'; Codehighlighter1_159_343_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_159_343_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_159_343_Closed_Text.style.display='none'; Codehighlighter1_159_343_Open_Image.style.display='inline'; Codehighlighter1_159_343_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> Map</span><span style="COLOR: rgb(0,0,0)">&lt;</span><span style="COLOR: rgb(0,0,0)">String, Locale</span><span style="COLOR: rgb(0,0,0)">&gt;</span><span style="COLOR: rgb(0,0,0)"> getLocales() </span><span id="Codehighlighter1_159_343_Closed_Text" style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)"><img src="http://www.blogjava.net/images/dot.gif" /></span><span id="Codehighlighter1_159_343_Open_Text"><span style="COLOR: rgb(0,0,0)">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        Map</span><span style="COLOR: rgb(0,0,0)">&lt;</span><span style="COLOR: rgb(0,0,0)">String, Locale</span><span style="COLOR: rgb(0,0,0)">&gt;</span><span style="COLOR: rgb(0,0,0)"> locales </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)"> Hashtable</span><span style="COLOR: rgb(0,0,0)">&lt;</span><span style="COLOR: rgb(0,0,0)">String, Locale</span><span style="COLOR: rgb(0,0,0)">&gt;</span><span style="COLOR: rgb(0,0,0)">(</span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        locales.put(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">American English</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">, Locale.US);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        locales.put(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Simplified Chinese</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">, Locale.CHINA);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: rgb(0,0,255)">return</span><span style="COLOR: rgb(0,0,0)"> locales;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: rgb(0,0,0)"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div><span style="FONT-SIZE: smaller; FONT-STYLE: italic">tutorial/Locales.java</span><br /><br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)">&lt;%</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">@taglib prefix</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">s</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> uri</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">/struts-tags</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"></span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)">%&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">script </span><span style="COLOR: rgb(255,0,0)">type</span><span style="COLOR: rgb(0,0,255)">="text/javascript"</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"><br /></span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">&lt;!--</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"><br />    </span><span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">function</span><span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> langSelecter_onChanged() {<br />        document.langForm.submit();<br />    }<br /></span><span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">//</span><span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">--&gt;</span><span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">script</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">s:set </span><span style="COLOR: rgb(255,0,0)">name</span><span style="COLOR: rgb(0,0,255)">="SESSION_LOCALE"</span><span style="COLOR: rgb(255,0,0)"> value</span><span style="COLOR: rgb(0,0,255)">="#session['WW_TRANS_I18N_LOCALE']"</span><span style="COLOR: rgb(255,0,0)"></span><span style="COLOR: rgb(0,0,255)">/&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">s:bean </span><span style="COLOR: rgb(255,0,0)">id</span><span style="COLOR: rgb(0,0,255)">="locales"</span><span style="COLOR: rgb(255,0,0)"> name</span><span style="COLOR: rgb(0,0,255)">="tutorial.Locales"</span><span style="COLOR: rgb(255,0,0)"></span><span style="COLOR: rgb(0,0,255)">/&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">form </span><span style="COLOR: rgb(255,0,0)">action</span><span style="COLOR: rgb(0,0,255)">="&lt;s:url includeParams="</span><span style="COLOR: rgb(255,0,0)">get" encode</span><span style="COLOR: rgb(0,0,255)">="true"</span><span style="COLOR: rgb(255,0,0)"></span><span style="COLOR: rgb(0,0,255)">/&gt;</span><span style="COLOR: rgb(0,0,0)">" name="langForm" <br />    style="background-color: powderblue; padding-top: 4px; padding-bottom: 4px;"&gt;<br />    Language: </span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">s:select </span><span style="COLOR: rgb(255,0,0)">label</span><span style="COLOR: rgb(0,0,255)">="Language"</span><span style="COLOR: rgb(255,0,0)"> <br />        list</span><span style="COLOR: rgb(0,0,255)">="#locales.locales"</span><span style="COLOR: rgb(255,0,0)"> listKey</span><span style="COLOR: rgb(0,0,255)">="value"</span><span style="COLOR: rgb(255,0,0)">    listValue</span><span style="COLOR: rgb(0,0,255)">="key"</span><span style="COLOR: rgb(255,0,0)"><br />        value</span><span style="COLOR: rgb(0,0,255)">="#SESSION_LOCALE == null ? locale : #SESSION_LOCALE"</span><span style="COLOR: rgb(255,0,0)"><br />        name</span><span style="COLOR: rgb(0,0,255)">="request_locale"</span><span style="COLOR: rgb(255,0,0)"> id</span><span style="COLOR: rgb(0,0,255)">="langSelecter"</span><span style="COLOR: rgb(255,0,0)"> <br />        onchange</span><span style="COLOR: rgb(0,0,255)">="langSelecter_onChanged()"</span><span style="COLOR: rgb(255,0,0)"> theme</span><span style="COLOR: rgb(0,0,255)">="simple"</span><span style="COLOR: rgb(255,0,0)"></span><span style="COLOR: rgb(0,0,255)">/&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">form</span><span style="COLOR: rgb(0,0,255)">&gt;</span></div><span style="FONT-SIZE: smaller; FONT-STYLE: italic">LangSelector.jsp</span><p>上述代码的原理为，LangSelector.jsp先实例化一个Locales对象，并把对象的Map类型的属性locales赋予下拉列表（select）。如此一来，下拉列表就获得可用语言的列表。大家看到LangSelector有&lt;s:form&gt;标志和一段Javascript脚本，它们的作用就是在用户在下拉列表中选择了后，提交包含“reqeust_locale”变量的表单到Action。在打开页面时，为了下拉列表的选中的当前区域，我们需要到session取得当前区域（键为“WW_TRANS_I18N_LOCALE”的属性），而该属性在没有设置语言前是为空的，所以通过值栈中locale属性来取得当前区域（用户浏览器所设置的语言）。</p>你可以把LangSelector.jsp作为一个控件使用，方法是在JSP页面中把它包含进来，代码如下所示： 
<div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">s:include </span><span style="COLOR: rgb(255,0,0)">value</span><span style="COLOR: rgb(0,0,255)">="/LangSelector.jsp"</span><span style="COLOR: rgb(255,0,0)"></span><span style="COLOR: rgb(0,0,255)">/&gt;</span></div><br />在例1中的HellloWorld.jsp中&lt;body&gt;后加入上述代码，并在struts.xml中新建Action，代码如下：<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">action </span><span style="COLOR: rgb(255,0,0)">name</span><span style="COLOR: rgb(0,0,255)">="HelloWorld"</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br />    </span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">result</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)">/HelloWorld.jsp</span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">result</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">action</span><span style="COLOR: rgb(0,0,255)">&gt;</span></div><br />或者，如果你多个JSP需要实现上述功能，你可以使用下面的通用配置，而不是为每一个JSP页面都新建一个Action。<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">action </span><span style="COLOR: rgb(255,0,0)">name</span><span style="COLOR: rgb(0,0,255)">="*"</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br />    </span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">result</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)">/{1}.jsp</span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">result</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">action</span><span style="COLOR: rgb(0,0,255)">&gt;</span></div><br />分布运行程序，在浏览器的地址栏中输入<a href="http://localhost:8080/Struts2_i18n/HelloWorld.action">http://localhost:8080/Struts2_i18n/HelloWorld.action</a>，出现图4所示页面：<br /><img alt="图3 HelloWorld.action" src="http://www.blogjava.net/images/blogjava_net/max/16758/r_imag3.gif" /><br /><span style="FONT-SIZE: smaller; MARGIN-BOTTOM: 8px; FONT-STYLE: italic">图3 HelloWorld.action<br /></span><br />在下拉列表中，选择“American English”，出现图5所示页面：<br /><img alt="图3 HelloWorld.action" src="http://www.blogjava.net/images/blogjava_net/max/16758/r_imag4.gif" /><br /><span style="FONT-SIZE: smaller; MARGIN-BOTTOM: 8px; FONT-STYLE: italic">图4 HelloWorld.action</span><br /><table style="BORDER-RIGHT: rgb(240,192,0) 1px solid; BORDER-TOP: rgb(240,192,0) 1px solid; MARGIN-TOP: 8px; MARGIN-BOTTOM: 8px; BORDER-LEFT: rgb(240,192,0) 1px solid; BORDER-BOTTOM: rgb(240,192,0) 1px solid; BACKGROUND-COLOR: rgb(255,255,206); TEXT-ALIGN: left" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td style="PADDING-RIGHT: 4px; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px"><img src="http://cwiki.apache.org/confluence/images/icons/emoticons/lightbulb_on.gif" /></td><td style="PADDING-RIGHT: 4px; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px; FONT-FAMILY: 华文仿宋">可能大家会问为什么一定要通过Action来访问页面呢？<br />你可以试一下不用Action而直接用JSP的地址来访问页面，结果会是无论你在下拉列表中选择什么，语言都不会改变。这表示不能正常运行的。其原因为如果直接使用JSP访问页面，Struts 2.0在web.xml的配置的过滤器（Filter）就不会工作，所以拦截器链也不会工作。</td></tr></tbody></table></li></ol><img src ="http://www.blogjava.net/zjhgx/aggbug/292516.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zjhgx/" target="_blank">david hu</a> 2009-08-25 14:56 <a href="http://www.blogjava.net/zjhgx/archive/2009/08/25/292516.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts 2.0的Action讲解(转自http://www.blogjava.net/max/archive/2006/10/25/77157.html)</title><link>http://www.blogjava.net/zjhgx/archive/2009/08/20/291964.html</link><dc:creator>david hu</dc:creator><author>david hu</author><pubDate>Thu, 20 Aug 2009 07:47:00 GMT</pubDate><guid>http://www.blogjava.net/zjhgx/archive/2009/08/20/291964.html</guid><wfw:comment>http://www.blogjava.net/zjhgx/comments/291964.html</wfw:comment><comments>http://www.blogjava.net/zjhgx/archive/2009/08/20/291964.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zjhgx/comments/commentRss/291964.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zjhgx/services/trackbacks/291964.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 有Struts 1.x经验的朋友都知道Action是Struts的核心内容，当然Struts 2.0也不例外。不过，Struts 1.x与Struts 2.0的Action模型很大的区别。																														 										Struts 1.x										Stuts 2.0																...&nbsp;&nbsp;<a href='http://www.blogjava.net/zjhgx/archive/2009/08/20/291964.html'>阅读全文</a><img src ="http://www.blogjava.net/zjhgx/aggbug/291964.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zjhgx/" target="_blank">david hu</a> 2009-08-20 15:47 <a href="http://www.blogjava.net/zjhgx/archive/2009/08/20/291964.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>常用的Struts 2.0的标志（Tag）介绍(转)</title><link>http://www.blogjava.net/zjhgx/archive/2009/08/20/291949.html</link><dc:creator>david hu</dc:creator><author>david hu</author><pubDate>Thu, 20 Aug 2009 06:43:00 GMT</pubDate><guid>http://www.blogjava.net/zjhgx/archive/2009/08/20/291949.html</guid><wfw:comment>http://www.blogjava.net/zjhgx/comments/291949.html</wfw:comment><comments>http://www.blogjava.net/zjhgx/archive/2009/08/20/291949.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zjhgx/comments/commentRss/291949.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zjhgx/services/trackbacks/291949.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 在上一篇文章《为Struts 2.0做好准备》中，我过于详细地介绍了Struts 2.0开发环境和运行环境的配置，所以，本文很少涉及的以上两方面的细节。如果，您看完《为Struts 2.0做好准备》后，还有什么不明白，或者没法运行文中例子，请联系我。我的E-MAIL：Max.M.Yuan@gmail.com。		在介绍常用标志前，我想先从总体上，对Struts 1.x与Struts 2.0的标...&nbsp;&nbsp;<a href='http://www.blogjava.net/zjhgx/archive/2009/08/20/291949.html'>阅读全文</a><img src ="http://www.blogjava.net/zjhgx/aggbug/291949.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zjhgx/" target="_blank">david hu</a> 2009-08-20 14:43 <a href="http://www.blogjava.net/zjhgx/archive/2009/08/20/291949.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>为Struts 2.0做好准备(转)</title><link>http://www.blogjava.net/zjhgx/archive/2009/08/20/291947.html</link><dc:creator>david hu</dc:creator><author>david hu</author><pubDate>Thu, 20 Aug 2009 06:38:00 GMT</pubDate><guid>http://www.blogjava.net/zjhgx/archive/2009/08/20/291947.html</guid><wfw:comment>http://www.blogjava.net/zjhgx/comments/291947.html</wfw:comment><comments>http://www.blogjava.net/zjhgx/archive/2009/08/20/291947.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zjhgx/comments/commentRss/291947.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zjhgx/services/trackbacks/291947.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;Struts作为MVC 2的Web框架，自推出以来不断受到开发者的追捧，得到用广泛的应用。作为最成功的Web框架，Struts自然拥有众多的优点：    MVC 2模型的使用    功能齐全的标志库（Tag Library）    开放源代码 但是，所谓&#8220;金无赤金，人无完人&#8221;，Struts自身也有不少的缺点：    需要编写的...&nbsp;&nbsp;<a href='http://www.blogjava.net/zjhgx/archive/2009/08/20/291947.html'>阅读全文</a><img src ="http://www.blogjava.net/zjhgx/aggbug/291947.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zjhgx/" target="_blank">david hu</a> 2009-08-20 14:38 <a href="http://www.blogjava.net/zjhgx/archive/2009/08/20/291947.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>