﻿<?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-konhon-随笔分类-Struts</title><link>http://www.blogjava.net/konhon/category/3029.html</link><description>忘掉過去，展望未來。找回自我，超越自我。
&lt;br&gt;
&lt;b&gt;逃避不一定躲的过, 面对不一定最难过, 孤单不一定不快乐, 得到不一定能长久, 失去不一定不再拥有, 可能因为某个理由而伤心难过, 但我却能找个理由让自己快乐.&lt;/b&gt;&lt;br&gt;&lt;p&gt;
&lt;!-- Search Google --&gt;
&lt;left&gt;
&lt;form method="get" action="http://www.google.com/custom" target="google_window"&gt;
&lt;table&gt;
&lt;tr&gt;&lt;td nowrap="nowrap" valign="top" align="left" height="32"&gt;
&lt;a href="http://www.google.com/"&gt;
&lt;img src="http://www.google.com/logos/Logo_25wht.gif" border="0" alt="Google" align="middle"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;input type="text" name="q" size="31" maxlength="255" value=""&gt;&lt;/input&gt;
&lt;input type="submit" name="sa" value="搜索"&gt;&lt;/input&gt;
&lt;input type="hidden" name="client" value="pub-5408663347953425"&gt;&lt;/input&gt;
&lt;input type="hidden" name="forid" value="1"&gt;&lt;/input&gt;
&lt;input type="hidden" name="ie" value="UTF-8"&gt;&lt;/input&gt;
&lt;input type="hidden" name="oe" value="UTF-8"&gt;&lt;/input&gt;
&lt;input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1;"&gt;&lt;/input&gt;
&lt;input type="hidden" name="hl" value="zh-CN"&gt;&lt;/input&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/form&gt;
&lt;/left&gt;
&lt;!-- Search Google --&gt;
</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 11:09:32 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 11:09:32 GMT</pubDate><ttl>60</ttl><item><title>配置Struts应用(原创) </title><link>http://www.blogjava.net/konhon/archive/2006/12/03/85157.html</link><dc:creator>konhon 优华</dc:creator><author>konhon 优华</author><pubDate>Sun, 03 Dec 2006 02:38:00 GMT</pubDate><guid>http://www.blogjava.net/konhon/archive/2006/12/03/85157.html</guid><wfw:comment>http://www.blogjava.net/konhon/comments/85157.html</wfw:comment><comments>http://www.blogjava.net/konhon/archive/2006/12/03/85157.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/konhon/comments/commentRss/85157.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/konhon/services/trackbacks/85157.html</trackback:ping><description><![CDATA[<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">Struts应用采用两个基于XML的配置文件来配置,分别是web.xml和struts-cofig.xml文件.web.xml文件是配置所有web应用的而struts-config.xml文件是struts专用的配置文件,事实上也是可以根据需要给这个配置文件起其他名称的.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">Web应用的发布描述文件:web应用发布描述文件可以在应用开着者,发布者和组装者之间传递配置信息,Web容器在启动的时候从该文件中读取配置信息,根据它来装载和配置web应用.文档类型定义DTD对XML文档的格式做了定义,DTD吧XML文档划分为元素,属性,实体每一种XML文档都有独自的DTD文件.可以从网上下载.&lt;web-app&gt;元素是web.xml的根元素,其他元素必须嵌入在&lt;web-app&gt;元素之内.要注意的是子元素也是有顺序的比如必须是首先&lt;servlet&gt;,然后&lt;servlet-mapping&gt;最后&lt;taglib&gt;.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体">为<span lang="EN-US">Struts应用配置Web.xml文件:首先最重要的一步是配置ActionServlet,这个用&lt;servlet&gt;标签的servlet-name属性起一个名字叫action,然后用servlet-class属性指定ActionServlet的类.然后用&lt;servlet-mapping&gt;标签的servlet-name属性指定action,在用url-pattern指定接收范围是*.do的请求.不管应用中包含了多少子应用,都只需要配置一个ActionServlet,类来出来应用中的不同的功能,其实者就是不必要的,因为Servlet本身就是多线程的,而且目前Struts只允许配置一个ActionServlet.声明ActionServlet的初始化参数:&lt;servlet&gt;的&lt;init-param&gt;子元素用来配置Servlet的初始化参数.param-name设置config参数名.param-value设置struts-config.xml的路径参数值.<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体">配置欢迎使用清单<span lang="EN-US">:如果客户访问Web的时候值是访问了WEB应用的根目录URL.没有具体的指定文件,Web会自动调用Web的欢迎文件.&lt;welcome-file-list&gt;元素来配置的.通过其中的&lt;welcome-file&gt;欢迎页面&lt;/welcome-file&gt;来配置.<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体">配置错误处理<span lang="EN-US">:尽管Struts框架功能强大的错误处理机制,但是不能保证处理所有的错误或者异常.当错误发生时,如果框架不能处理这种错误,把错误抛弃给Web容器,在默认的情况下web容器会想客户端返回错误信息.如果想避免让客户看到原始的错误信息,可以在Web应用发布描述文件中配置&lt;error-page&gt;元素.通过&lt;error-code&gt;404来定义错误的类型.然后通过&lt;location&gt;要处理错误的JSP页面来对错误进行处理.还可以用&lt;exception-type&gt;来设置异常,然后通过&lt;location&gt;来处理异常的JSP页面来处理异常.<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体">配置<span lang="EN-US">Struts标签库:这个就和以前学到的JSP自定义标签类似,配置元素为&lt;taglib&gt;来配置.&lt;taglib-uri&gt;这个指定标签库的uri,类似起一个名称.&lt;taglib-location&gt;这个是标签库的位置也就是实际所在的路径.通过这样的方法引入一个标签库,然后在前台JSP页面就可以通过自己定义的URI来调用标签.<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">Struts配置文件:struts-config.xml文件.首先研讨一下org.apache.struts.config包,在struts应用启动的时候会把Struts配置文件信息读取到内存中,并把它们存放在config包中相关的JavaBean类的实例中.包中的每一个类都和struts配置文件中特定的配置元素对应,ModuleConfig在Struts框架中扮演了十分重要的角色,它是整个config包的核心,在Struts运行时来存放整个应用的配置信息.如果有多个子应用都会有一个ModuleConfig对象,它和Struts文件根元素的&lt;struts-config&gt;对应.根元素中包含&lt;form-bean&gt;&lt;action&gt;&lt;forward&gt;等元素.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">&lt;struts-config&gt;元素:时Struts配置文件的根元素,和它对应的配置类ModuleConfig类,&lt;struts-config&gt;元素有8个子元素.他们的DTD定义是data-sources?form-bean? global-exception?global-forwards?action-mapping?controller?message-resources?plug-in*在Struts配置文件中,必须按照DTD指定的先手顺序来配置&lt;struts-config&gt;元素的各个子元素,如果颠倒了这些子元素的顺序,会产生错误.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">&lt;data-sources&gt;元素:用来配置应用所需要的数据源,数据源负责创建和特定的数据库的连接.许多数据源采用连接池的机制实现.以便提高数据库访问的性能.JAVA语言提供了javax.sql.DataSource接口,所有的数据源都必须实现这个接口.许多应用服务器和Web服务器都提供了数据源组件.很多数据库厂商也提供了数据源的实现.&lt;data-sources&gt;元素包含多个&lt;data-source&gt;子元素永远配置特定的数据源.他们可以包含多个&lt;set-property&gt;子元素用于设置数据源的各种属性.配置了数据源以后,就可以在Action类中访问数据源,在Action中定义了getDataSource(HttpRequest)方法,用于获取数据源对象的引用.然后可以利用DataSource对象调用getConnection获取一个连接对象对数据库进行操作.在配置文件中声明多个数据源的时候需要为每一个数据源分配唯一的Key值,通过这个来表示特定的数据源.获取特定的数据源的时候可以用dataSource = getDataSource(reqeust,”A”);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">&lt;form-beans&gt;元素:用来配置多个ActionForm,包含一个或者N个&lt;form-bean&gt;子元素.每个&lt;form-bean&gt;元素都包含多个属性.className指定和&lt;form-bean&gt;匹配的类.name指定该ActionForm的唯一标识符,这个属性是必须的以后作为引用使用.type指定ActionForm类的完整类名,这个属性也是必须的.注意包名也要加上.&lt;form-property&gt;是指定动态的Form的元素,以后会深入了解.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">&lt;global-exception&gt;元素:用于配置异常处理,元素可以包含一个或者多个&lt;exception&gt;元素,用来设置JAVA异常和异常处理类ExceptionHandler之间的映射.className指定和元素对应的配置类,默认的不用动.handler指定异常处理类默认是ExceptionHandler.key指定在本地资源文件中异常的消息Key,path指定当前异常发生的时候转发的路径.scope指定ActionMessages实例存放的范围.type指定需要处理异常类的名字,必须的.bundle指定Resource Bundle.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">&lt;global-forwards&gt;元素:用来声明全局转发,元素可以有一个或者N个&lt;forward&gt;元素组成,用于把一个逻辑名映射到特定的URL,通过这种方法Action类或者JSP页面无需指定URL,只要指定逻辑名称就可以实现请求转发或者重定向.这样可以减少控制组件和视图的聚合.易于维护.className对应的配置类.contextRelative如果为true表示当path属性以/开头的时候,给出的是对应的上下文URL默认是false.name转发路径的逻辑名,必须写.path转发或者重定向的URL,必须写必须是以/开头.redirect设置为true的时候表示执行重定向操作,此项为false的时候,表示执行请求转发操作.重定向与请求转发的区别以后就是重定向是把请求生成应答给客户端然后在重新发送给定向的URL,浏览器地址栏会有显示.而转发就是直接把请求转发给本应用的另一个文件,不生成应答所以客户端IE没显示.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<strong>
						<span lang="EN-US" style="FONT-FAMILY: 宋体">&lt;action-mapping&gt;元素:包含一个或者N个&lt;action&gt;元素,描述了从特定的请求路径到响应的Action的映射.在&lt;action&gt;元素中可以包含多个&lt;exception&gt;和&lt;forward&gt;子元素,他们分别配置局部异常处理和局部转发.attribute设置Action关联的ActionForm在request或者session范围内的key.就是在request或者session共享内的名称.className对应配置元素的类.默认的是ActionMapping.forward指定转发URL路径include指定包含URL路径.input指定包含表单的URL,当表单验证失败的时候发送的URL.name,指定和该Action关联的Form名字.该名字必须是在form-bean中定义过的,可写可不写.path必须/开头的方位Action的路径.parameter指定Action配置参数.在Action的execute()方法中可以调用ActionMapping的getParameter()方法来读取匹配的参数.roles指定允许调用该Action的安全角色,多个角色之间逗号格开.scope指定Form的存在范围.默认是session.tyep指定Action的完整类名.unknown如果是true表示可以处理用户发出的所有的无效的ActionURL默认是false.validate指定是否调用ActionForm的validate方法.<o:p></o:p></span>
				</strong>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">&lt;controller&gt;元素:用于配置ActionServlet.buffreSize指定上载文件的输入缓冲大小.该属性为可选默认4096.className指定元素对应的配置类,ControllerConfig.然后是contentType指定响应结果内容类型和字符编码,该属性为可选,默认是text/html如果在Action或者JSP网页也设置了类型内容,会覆盖这个.locale指定是否把Locale对象保存到当前用户的session中默认false.tempDir指定处理文件上载的临时工作目录.nochache如果是true在响应结果中加入特定的头参数.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">&lt;message-resources&gt;元素:用来配置Resource Bundle.用于存放本地文本消息文件.className元素对应的配置类.MessageResourcesConfig.factory指定消息的工厂类.key指定文件存放的Servlet对象中采用的属性Key.null指定如何处理未知消息.parameter指定消息的文件名.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">&lt;plug-in&gt;元素:用于配置Struts插件.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体">配置多应用模块<span lang="EN-US">:所有的子应用都可以共享同一个ActionServlet实例,但是每个子应用都有单独的配置文件.把应用划分为多个子应用模块.首先为每个应用创建单独的Struts配置文件,在web.xml的ActionServlet配置代码中添加几个子应用信息.采用&lt;forward&gt;元素来实现应用之间的切换.<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US" style="FONT-FAMILY: 宋体">Digester组件:是一个Apache的另一个开源代码项目.当Struts被初始化的时候,首先会读取并解析配置文件,框架采用Digester组件来且西配置文件.然后创建config包中的对象.者对象用于存放配置信息.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体">其实配置文件不难<span lang="EN-US">,只要都理其中的原理就OK了.真正实际的项目开发中,采用的工具例如Eclipse系列,提供了相应的插件,在创建一个Struts工程的时候配置文件的标签都是自动生成的,而我们只需要往里面填写属性就OK了. (网友们的支持,是我继续写技术文章的动力!)<o:p></o:p></span></span>
		</p><img src ="http://www.blogjava.net/konhon/aggbug/85157.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/konhon/" target="_blank">konhon 优华</a> 2006-12-03 10:38 <a href="http://www.blogjava.net/konhon/archive/2006/12/03/85157.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts入门经验</title><link>http://www.blogjava.net/konhon/archive/2005/08/27/11274.html</link><dc:creator>konhon 优华</dc:creator><author>konhon 优华</author><pubDate>Sat, 27 Aug 2005 01:53:00 GMT</pubDate><guid>http://www.blogjava.net/konhon/archive/2005/08/27/11274.html</guid><wfw:comment>http://www.blogjava.net/konhon/comments/11274.html</wfw:comment><comments>http://www.blogjava.net/konhon/archive/2005/08/27/11274.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/konhon/comments/commentRss/11274.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/konhon/services/trackbacks/11274.html</trackback:ping><description><![CDATA[<STRONG>Struts安装：<BR></STRONG>首先请到http://jakarta.apache.org/Struts下载Struts，建议使用release版，现在最高版本为1.1，下载后得到的是一个ZIP文件。<BR>将ZIP包解开，可以看到这个目录：lib和webapps，webapps下有一些WAR文件。假设你的Tomcat装在c:\Tomcat下，则将那些WAR文件拷贝到C:\Tomcat\webapps，重新启动Tomcat即可。打开浏览器，在地址栏中输入：http://localhost:8080/Struts-example/index.jsp，若能见到“powered by Struts”的深蓝色图标，即说明成功了。这是Struts自带的一个例子，附有详细的说明文档，可以做为初学者的入门教程。另外，Struts还提供了一系统实用对象：XML处理、通过Java reflection APIs自动处理JavaBeans属性、国际化的提示和消息等<BR><BR><B>一个实例：</B><BR>一个用户注册系统，用户通过网页输入相关信息：注册ID号，密码，EMAIL，若注册成功，则返回成功提示信息，反之出现注册失败提示信息。<BR>以下是相关文件的部分核心代码。<BR><BR><B>项目建立：</B><BR>正式开发前，需要在Tocmat（我的tomcat装在c:\tomcat）中建立此项目。比较快的一种建立方式为：在C:\tomcat\webapps下新建目录test，再将C:\tomcat\webapps\struts-example下的<BR>WEB-INF目录拷贝到test目录下，然后将test\WEB-INF下的src和classes目录清空，以及struts-config.xml文件中内容清空即可。这样，我们需要的Struts类包及相关的配置文件就都齐了。<BR>开发时，将JSP文件放在test目录下，Java原文件放在test\WEB-INF\src下，编译后的类文件放在test\WEB-INF\classes下。<BR><BR><B>注册页面：reguser.jsp</B><BR>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<DIV><IMG id=Codehighlighter1_2_62_Open_Image onclick="this.style.display='none'; Codehighlighter1_2_62_Open_Text.style.display='none'; Codehighlighter1_2_62_Closed_Image.style.display='inline'; Codehighlighter1_2_62_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_2_62_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2_62_Closed_Text.style.display='none'; Codehighlighter1_2_62_Open_Image.style.display='inline'; Codehighlighter1_2_62_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">&lt;%</SPAN><SPAN id=Codehighlighter1_2_62_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_2_62_Open_Text><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">@&nbsp;page&nbsp;contentType</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">text/html;charset=UTF-8</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;language</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">java</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_68_121_Open_Image onclick="this.style.display='none'; Codehighlighter1_68_121_Open_Text.style.display='none'; Codehighlighter1_68_121_Closed_Image.style.display='inline'; Codehighlighter1_68_121_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_68_121_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_68_121_Closed_Text.style.display='none'; Codehighlighter1_68_121_Open_Image.style.display='inline'; Codehighlighter1_68_121_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">&lt;%</SPAN><SPAN id=Codehighlighter1_68_121_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_68_121_Open_Text><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">@&nbsp;taglib&nbsp;uri</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">/WEB-INF/Struts-bean.tld</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;prefix</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">bean</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_127_180_Open_Image onclick="this.style.display='none'; Codehighlighter1_127_180_Open_Text.style.display='none'; Codehighlighter1_127_180_Closed_Image.style.display='inline'; Codehighlighter1_127_180_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_127_180_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_127_180_Closed_Text.style.display='none'; Codehighlighter1_127_180_Open_Image.style.display='inline'; Codehighlighter1_127_180_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">&lt;%</SPAN><SPAN id=Codehighlighter1_127_180_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_127_180_Open_Text><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">@&nbsp;taglib&nbsp;uri</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">/WEB-INF/Struts-html.tld</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;prefix</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">html</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html:html&nbsp;</SPAN><SPAN style="COLOR: #ff0000">locale</SPAN><SPAN style="COLOR: #0000ff">="true"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">head</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">title</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">RegUser</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">title</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html:base</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">head</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">body&nbsp;</SPAN><SPAN style="COLOR: #ff0000">bgcolor</SPAN><SPAN style="COLOR: #0000ff">="white"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html:errors</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html:form&nbsp;</SPAN><SPAN style="COLOR: #ff0000">action</SPAN><SPAN style="COLOR: #0000ff">="/regUserAction"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;focus</SPAN><SPAN style="COLOR: #0000ff">="logname"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">table&nbsp;</SPAN><SPAN style="COLOR: #ff0000">border</SPAN><SPAN style="COLOR: #0000ff">="0"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;width</SPAN><SPAN style="COLOR: #0000ff">="100%"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">tr</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">th&nbsp;</SPAN><SPAN style="COLOR: #ff0000">align</SPAN><SPAN style="COLOR: #0000ff">="right"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>Logname:<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">th</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">td&nbsp;</SPAN><SPAN style="COLOR: #ff0000">align</SPAN><SPAN style="COLOR: #0000ff">="left"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html:text&nbsp;</SPAN><SPAN style="COLOR: #ff0000">property</SPAN><SPAN style="COLOR: #0000ff">="logname"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;size</SPAN><SPAN style="COLOR: #0000ff">="20"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;maxlength</SPAN><SPAN style="COLOR: #0000ff">="20"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">tr</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">tr</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">th&nbsp;</SPAN><SPAN style="COLOR: #ff0000">align</SPAN><SPAN style="COLOR: #0000ff">="right"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>Password:<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">th</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">td&nbsp;</SPAN><SPAN style="COLOR: #ff0000">align</SPAN><SPAN style="COLOR: #0000ff">="left"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html:password&nbsp;</SPAN><SPAN style="COLOR: #ff0000">property</SPAN><SPAN style="COLOR: #0000ff">="password"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;size</SPAN><SPAN style="COLOR: #0000ff">="20"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;maxlength</SPAN><SPAN style="COLOR: #0000ff">="20"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">tr</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">tr</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">th&nbsp;</SPAN><SPAN style="COLOR: #ff0000">align</SPAN><SPAN style="COLOR: #0000ff">="right"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>E-mail:<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">th</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">td&nbsp;</SPAN><SPAN style="COLOR: #ff0000">align</SPAN><SPAN style="COLOR: #0000ff">="left"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html:password&nbsp;</SPAN><SPAN style="COLOR: #ff0000">property</SPAN><SPAN style="COLOR: #0000ff">="email"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;size</SPAN><SPAN style="COLOR: #0000ff">="30"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;maxlength</SPAN><SPAN style="COLOR: #0000ff">="50"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">tr</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">tr</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">td&nbsp;</SPAN><SPAN style="COLOR: #ff0000">align</SPAN><SPAN style="COLOR: #0000ff">="right"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html:submit&nbsp;</SPAN><SPAN style="COLOR: #ff0000">property</SPAN><SPAN style="COLOR: #0000ff">="submit"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="Submit"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">td&nbsp;</SPAN><SPAN style="COLOR: #ff0000">align</SPAN><SPAN style="COLOR: #0000ff">="left"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html:reset</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">tr</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">table</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">html:form</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">body</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">html:html</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV><BR><BR>此JSP页面不同于普通的JSP页，因为它大量运用了taglib，这些taglib对初学者而言，可能难于掌握，可这却是Struts的精华之一。灵活运用，将大大提高开发效率。<BR><BR><B>Struts-config.xml：</B><BR><BR>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<DIV><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Struts-config</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">form-beans</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">form-bean&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="regUserForm"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>type</SPAN><SPAN style="COLOR: #0000ff">="org.cjea.Struts.example.&nbsp;RegUserForm&nbsp;"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">form-beans</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">action-mappings</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">action&nbsp;</SPAN><SPAN style="COLOR: #ff0000">path</SPAN><SPAN style="COLOR: #0000ff">="/regUserAction"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>type</SPAN><SPAN style="COLOR: #0000ff">="&nbsp;org.cjea.Struts.example.RegUserAction&nbsp;"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>attribute</SPAN><SPAN style="COLOR: #0000ff">="&nbsp;regUserForm&nbsp;"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>scope</SPAN><SPAN style="COLOR: #0000ff">="request"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>validate</SPAN><SPAN style="COLOR: #0000ff">="false"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">forward&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="failure"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;path</SPAN><SPAN style="COLOR: #0000ff">="/&nbsp;messageFailure.jsp"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">forward&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="success"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;path</SPAN><SPAN style="COLOR: #0000ff">="/&nbsp;messageSuccess.jsp"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">action</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">action-mappings</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">Struts-config</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV><BR>Struts的核心是Controller，即ActionServlet，而ActionServlet的核心就是Struts-config.xml，Struts-config.xml集中了所有页面的导航定义。对于大型的WEB项目，通过此配置文件即可迅速把握其脉络，这不管是对于前期的开发，还是后期的维护或升级都是大有裨益的。掌握Struts-config.xml是掌握Struts的关键所在。<BR><BR><B>FormBean：RegUserForm</B><BR><BR>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<DIV><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">package&nbsp;org.cjea.Struts.example;<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>import&nbsp;javax.Servlet.http.HttpServletRequest;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>import&nbsp;org.apache.Struts.action.ActionForm;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>import&nbsp;org.apache.Struts.action.ActionMapping;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG id=Codehighlighter1_221_840_Open_Image onclick="this.style.display='none'; Codehighlighter1_221_840_Open_Text.style.display='none'; Codehighlighter1_221_840_Closed_Image.style.display='inline'; Codehighlighter1_221_840_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_221_840_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_221_840_Closed_Text.style.display='none'; Codehighlighter1_221_840_Open_Image.style.display='inline'; Codehighlighter1_221_840_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;final&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;RegUserForm&nbsp;extends&nbsp;ActionForm</SPAN><SPAN id=Codehighlighter1_221_840_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_221_840_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;String&nbsp;logname;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;String&nbsp;password;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;String&nbsp;email;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_316_365_Open_Image onclick="this.style.display='none'; Codehighlighter1_316_365_Open_Text.style.display='none'; Codehighlighter1_316_365_Closed_Image.style.display='inline'; Codehighlighter1_316_365_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_316_365_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_316_365_Closed_Text.style.display='none'; Codehighlighter1_316_365_Open_Image.style.display='inline'; Codehighlighter1_316_365_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;RegUserForm()</SPAN><SPAN id=Codehighlighter1_316_365_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_316_365_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>logname&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>password&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>email&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_395_418_Open_Image onclick="this.style.display='none'; Codehighlighter1_395_418_Open_Text.style.display='none'; Codehighlighter1_395_418_Closed_Image.style.display='inline'; Codehighlighter1_395_418_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_395_418_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_395_418_Closed_Text.style.display='none'; Codehighlighter1_395_418_Open_Image.style.display='inline'; Codehighlighter1_395_418_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;String&nbsp;getLogName()&nbsp;</SPAN><SPAN id=Codehighlighter1_395_418_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_395_418_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.logname;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_459_485_Open_Image onclick="this.style.display='none'; Codehighlighter1_459_485_Open_Text.style.display='none'; Codehighlighter1_459_485_Closed_Image.style.display='inline'; Codehighlighter1_459_485_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_459_485_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_459_485_Closed_Text.style.display='none'; Codehighlighter1_459_485_Open_Image.style.display='inline'; Codehighlighter1_459_485_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;setLogName(String&nbsp;logname)&nbsp;</SPAN><SPAN id=Codehighlighter1_459_485_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_459_485_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.logname&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;logname;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_528_556_Open_Image onclick="this.style.display='none'; Codehighlighter1_528_556_Open_Text.style.display='none'; Codehighlighter1_528_556_Closed_Image.style.display='inline'; Codehighlighter1_528_556_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_528_556_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_528_556_Closed_Text.style.display='none'; Codehighlighter1_528_556_Open_Image.style.display='inline'; Codehighlighter1_528_556_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;setPassWord(String&nbsp;password)&nbsp;</SPAN><SPAN id=Codehighlighter1_528_556_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_528_556_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.password&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;password;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_586_610_Open_Image onclick="this.style.display='none'; Codehighlighter1_586_610_Open_Text.style.display='none'; Codehighlighter1_586_610_Closed_Image.style.display='inline'; Codehighlighter1_586_610_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_586_610_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_586_610_Closed_Text.style.display='none'; Codehighlighter1_586_610_Open_Image.style.display='inline'; Codehighlighter1_586_610_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;String&nbsp;getPassWord()&nbsp;</SPAN><SPAN id=Codehighlighter1_586_610_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_586_610_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.password;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_647_669_Open_Image onclick="this.style.display='none'; Codehighlighter1_647_669_Open_Text.style.display='none'; Codehighlighter1_647_669_Closed_Image.style.display='inline'; Codehighlighter1_647_669_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_647_669_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_647_669_Closed_Text.style.display='none'; Codehighlighter1_647_669_Open_Image.style.display='inline'; Codehighlighter1_647_669_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;setEmail(String&nbsp;email)&nbsp;</SPAN><SPAN id=Codehighlighter1_647_669_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_647_669_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.email&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;email;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_696_717_Open_Image onclick="this.style.display='none'; Codehighlighter1_696_717_Open_Text.style.display='none'; Codehighlighter1_696_717_Closed_Image.style.display='inline'; Codehighlighter1_696_717_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_696_717_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_696_717_Closed_Text.style.display='none'; Codehighlighter1_696_717_Open_Image.style.display='inline'; Codehighlighter1_696_717_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;String&nbsp;getEmail()&nbsp;</SPAN><SPAN id=Codehighlighter1_696_717_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_696_717_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.email;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;reset(ActionMapping&nbsp;mapping,&nbsp;HttpServletRequest&nbsp;request)<BR><IMG id=Codehighlighter1_789_838_Open_Image onclick="this.style.display='none'; Codehighlighter1_789_838_Open_Text.style.display='none'; Codehighlighter1_789_838_Closed_Image.style.display='inline'; Codehighlighter1_789_838_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_789_838_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_789_838_Closed_Text.style.display='none'; Codehighlighter1_789_838_Open_Image.style.display='inline'; Codehighlighter1_789_838_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_789_838_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_789_838_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>logname&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>password&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>email&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV><BR>每一个FormBean 都必须继承ActionForm类，FormBean是对页面请求的封装。即把HTTP request 封装在一个对象中，需要说明的一点就是多个HTTP request可以共用一个FormBean，便于维护和重用。<BR><BR><B>ActionBean：RegUserAction</B><BR><BR>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<DIV><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">package&nbsp;org.cjea.Struts.example;<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>import&nbsp;javax.Servlet.http.</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>import&nbsp;org.apache.Struts.action.</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">;<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: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;final&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;RegUserAction&nbsp;extends&nbsp;Action<BR><IMG id=Codehighlighter1_147_430_Open_Image onclick="this.style.display='none'; Codehighlighter1_147_430_Open_Text.style.display='none'; Codehighlighter1_147_430_Closed_Image.style.display='inline'; Codehighlighter1_147_430_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_147_430_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_147_430_Closed_Text.style.display='none'; Codehighlighter1_147_430_Open_Image.style.display='inline'; Codehighlighter1_147_430_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_147_430_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_147_430_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;ActionForward&nbsp;perform(ActionMapping&nbsp;mapping,<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>ActionForm&nbsp;form,&nbsp;HttpServletRequest&nbsp;req,<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>HttpServletResponse&nbsp;res)<BR><IMG id=Codehighlighter1_268_428_Open_Image onclick="this.style.display='none'; Codehighlighter1_268_428_Open_Text.style.display='none'; Codehighlighter1_268_428_Closed_Image.style.display='inline'; Codehighlighter1_268_428_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_268_428_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_268_428_Closed_Text.style.display='none'; Codehighlighter1_268_428_Open_Image.style.display='inline'; Codehighlighter1_268_428_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_268_428_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_268_428_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>String&nbsp;title&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;req.getParameter(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">title</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>String&nbsp;password&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;req.getParameter(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">password</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>String&nbsp;email&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;req.getParameter(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">email</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG id=Codehighlighter1_403_425_Open_Image onclick="this.style.display='none'; Codehighlighter1_403_425_Open_Text.style.display='none'; Codehighlighter1_403_425_Closed_Image.style.display='inline'; Codehighlighter1_403_425_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_403_425_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_403_425_Closed_Text.style.display='none'; Codehighlighter1_403_425_Open_Image.style.display='inline'; Codehighlighter1_403_425_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_403_425_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_403_425_Open_Text><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>取得用户请求,做相应数据库操作，略<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV><BR>FormBean的产生是为了提供数据给ActionBean，在ActionBean中可以取得FormBean中封装的数据，经相应的逻辑处理后，调用业务方法完成相应业务要求。<BR><BR>Servlet的演变：在常规的 JSP，Servlet，JavaBean三层结构中，JSP实现View的功能，Servlet实现Controller的功能，JavaBean实现Model的实现。<BR><BR>在Struts中，将常规情况下的Servlet拆分与ActionServlet、FormBean、ActionBean三个部分。ActionServlet配合Struts-config.xml，专职完成页面导航，而不再负责具体的数据获取与相应逻辑，这两部分功能由FormBean和ActionBean来完成。<BR><BR><B>Struts优缺点</B><BR>优点：<BR>Struts跟Tomcat、Turbine等诸多Apache项目一样，是开源软件，这是它的一大优点。使开发者能更深入的了解其内部实现机制。<BR>除此之外，Struts的优点主要集中体现在两个方面：Taglib和页面导航。Taglib是Struts的标记库，灵活动用，能大大提高开发效率。另外，就目前国内的JSP开发者而言，除了使用JSP自带的常用标记外，很少开发自己的标记，或许Struts是一个很好的起点。<BR>关于页面导航，我认为那将是今后的一个发展方向，事实上，这样做，使系统的脉络更加清晰。通过一个配置文件，即可把握整个系统各部分之间的联系，这对于后期的维护有着莫大的好处。尤其是当另一批开发者接手这个项目时，这种优势体现得更加明显。<BR>缺点：<BR>Taglib是Struts的一大优势，但对于初学者而言，却需要一个持续学习的过程，甚至还会打乱你网页编写的习惯，但是，当你习惯了它时，你会觉得它真的很棒。<BR>Struts将MVC的Controller一分为三，在获得结构更加清晰的同时，也增加了系统的复杂度。<BR>Struts从产生到现在还不到半年，但已逐步越来越多运用于商业软件。虽然它现在还有不少缺点，但它是一种非常优秀的J2EE MVC实现方式，如果你的系统准备采用J2EE MVC架构，那么，不妨考虑一下Struts。<BR><BR><B>Struts实施经验：</B><BR>1、基于Struts架构的项目开发，首先需要有一个很好的整体规划，整个系统中包括哪几个模块，每个模块各需要多少FormBean和ActionBean等，而且最好有专人负责Struts-config.xml的管理。开发基于Struts的项目的难点在于配置管理，尤其是对Struts-config.xml的管理<BR><BR>2、如果你的项目非常紧，并且项目组中又没有富有经验的Struts开发人员，建议不要冒然采用Struts。Struts的掌握需要一个过程，对于一个熟练的JSP程序员，自学大概需要半个月左右的时间。如果结合titls，则需要更长的时间<BR><BR>3、如果你在网页中大量运用taglib，那么你的美工将做出部分牺牲。当你结合Tiles，功能增强的同时，这种牺牲尤为明显。当然，你对功能和美观的取舍由你自己决定<BR><BR>4、Taglib是一个好东西，但灵活运用它却需要一个过程，如果你不想在Taglib上花太多的时间，那么只需理解与FORM有关的几个标记，其它的标记就放着吧，以后再看，先去研究ActionServlet和Struts-config.xml，你会觉得很有成就感<BR><BR>5、Struts是否只适合于大型项目呢？No！Struts适合于各种大小的项目，当然，对于大型项目，它所体现出来的优势更加明显。<BR><BR><img src ="http://www.blogjava.net/konhon/aggbug/11274.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/konhon/" target="_blank">konhon 优华</a> 2005-08-27 09:53 <a href="http://www.blogjava.net/konhon/archive/2005/08/27/11274.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>