﻿<?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-Java技术专区--Hilly-随笔分类-web技术</title><link>http://www.blogjava.net/web/category/12526.html</link><description>主要是WEB应用方向</description><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2007 04:11:19 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2007 04:11:19 GMT</pubDate><ttl>60</ttl><item><title>为什么要使用EJB</title><link>http://www.blogjava.net/web/archive/2006/09/07/why_use_EJB.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 07 Sep 2006 12:04:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/09/07/why_use_EJB.html</guid><wfw:comment>http://www.blogjava.net/web/comments/68364.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/09/07/why_use_EJB.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/68364.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/68364.html</trackback:ping><description><![CDATA[<h2 align="center">为什么要使用EJB？</h2>
		<p align="center">来源：<a href="http://www.jdon.com/artichect/whyEJB.htm">http://www.jdon.com/artichect/whyEJB.htm</a></p>
		<p align="left">　　首先，我们必须明确，为什么要使用J2EE？J2EE优点是什么？使用J2EE的主要原因是多层结构，传统的两层C/S结构难于维护，稳定性极差，界面代码和数据库代码混淆在一起，牵一动百，多层结构使得界面和数据库完全分离，并且诞生了中间件这样的技术，如下图：</p>
		<p align="center">
				<img height="186" src="http://www.jdon.com/artichect/images/middle.png" width="400" />
		</p>
		<h3>Web+EJB能组成真正的多层结构</h3>
		<p>　　为什么使用EJB我原先认为这不是一个讨论的话题，因为EJB是J2EE重要的组成部分，可以说没有EJB的J2EE只是一种Web系统，这样的系统非常容易丧失了多层结构的大部分优点（仔细想想那些混合多种层次功能JavaBeans和传统两层结构有什么区别？）。</p>
		<p>　　当然，可以人为地在Javabeans之间进行层次划分，例如Hibernate算数据持久层，某些JavaBeans是业务核心层，但是因为都是普通JavaBeans，这种划分没有一种强制性和明显标志性，这样的系统更换了主创人员或设计师，可能就会被新的程序员修改得非常混乱。</p>
		<p>　　我们先看看一个包含EJB的J2EE系统是如何清晰地表达层次。如下图：</p>
		<p align="center">
				<img height="300" src="http://www.jdon.com/artichect/images/j2ee.png" width="482" />
		</p>
		<p>　　Web完全只是一个MVC模式的实现，关键业务核心是在EJB的服务层实现，这样做的优点是，Web只负责界面相关部分，因为，如果是一个智能客户端，如Swing或J2ME，在不需要修改任何业务核心的情况下能够方便地更换。同样，提供Web Services功能，也只是在 Web层修改，不会涉及EJB方面的修改，同样保证了系统的稳定性，保证了系统升级和未来的扩展性。</p>
		<p>　　如果不使用EJB，在EJB服务层实现的业务核心将由普通JavaBeans实现，使用何种架构或设计能够保证负责MVC的JavaBeans和负责业务核心的JavaBeans清晰地分开，又如何保证在新的程序员不会破坏和打乱你精心布局的JavaBeans架构？</p>
		<h3>EJB提供性能优化支持</h3>
		<p>　　最主要的是性能问题，由于以前国内中文Java网站有些人弯曲EJB，认为EJB性能低，其实这是一种非常肤浅错误的认识，我们首先看看在一般Java环境中是如何提高性能。</p>
		<p>　　假定一个JavaBeans为A，那么一般使用这个JavaBeans命令如下：</p>
		<p>　　A a = new A();</p>
		<p>　　但是，在高访问量的环境中，new A()其实是很费时消耗系统性能的，因此，能不能在软件系统启动时候就预先建立一些对象，这样，系统运行时，从这些已经生成的对象池中借用一个，这样，就无需在使用时进行New，节约了开销，提高了性能，因此，真正成熟性能解决方案都是需要对象池等支持。</p>
		<p>　　在一个纯Web结构的系统（也就是只能运行在Tomat环境中），例如Struts + Hibernate等这样的系统，除非自己动手做，一般是没有对象池技术支持的，因此他们的性能只能算是Demo演示版本的性能，根本无法承受大容量并发访问，也无法称为一个成熟的系统，所以，我们研究成熟的开源Web系统，如Jive、OFBize，LifeRay等，他们都在Web层拥有自己的对象池和缓存池。</p>
		<p>　　对象池和缓存机制是J2EE必须的吗？当然，是所有成熟系统必须的，Windows系统如果去掉缓存将会变得怎样？</p>
		<p>　　自己动手开发对象池和缓存机制并不是一件简单的事情，需要对多线程以及同步锁等底层原理有深层次的把握，这其实也是一门非常深入的Java研究分支，所以，你可以抛开你的客户焦急的催促，精心研究开发自己的对象池和缓存池。</p>
		<p>　　但是，EJB容器（如JBoss）已经提供了对象池和缓存机制，所以，没有事务机制的无状态Session Bean的性能肯定要强于普通JavaBeans。EJB容器不但在单机中提供了对象池和缓存，而且可以跨服务器实现动态负载平衡，这些都无需开发者自己开发任何软件代码，结构如下：</p>
		<p align="center">
				<img height="227" src="http://www.jdon.com/artichect/images/ejb.png" width="304" />
		</p>
		<h3 align="left">EJB组件能提供真正的可重用框架</h3>
		<p align="left">　　每一个jar包代表一个EJB组件，一个系统可以由多个可重用的EJB组件构成，例如：树形结构EJB组件；自增序号EJB组件；用户资料EJB组件等，这样的EJB组件可以象积木一样搭配在大部分应用系统中，提高了系统的开发效率，保证了开发质量。</p>
		<p align="left">　　下图是某个新的具体系统时应用到的EJB组件图，在这个新的应用中，由于使用了以前大量可重用的EJB组件，新的开发工作基本集中在界面设计和流程安排上：</p>
		<p align="center">
				<img height="421" src="http://www.jdon.com/artichect/images/ejbcomps.png" width="297" />
		</p>
		<h3>EJB提供了事务机制</h3>
		<p>　　事务机制对于一些关键事务是很重要的，例如ATM机提款，提款有多个动作：修改数据库以及数钱等，如果这其中有任何一个环节出错，那么其它已经实现的操作必须还原，否则，就会出现，提款人没有拿到钱，但是卡上已经扣款等不可思议的事情发生。</p>
		<p>　　EJB提供的事务机制非常周全，但事务机制带来的缺点是性能的降低，因此，有些人认为EJB很重，因为在实际应用中，有的用户系统可能不需要事务机制，只是需要EJB提供的性能优化机制，这样，如果使用EJB，就象叫一个人来背东西，他除了背着我要的东西外，还背着我不要的东西。</p>
		<p>　　除非你是一个完美主义，在一般企业应用或数据库系统应用中，EJB不会对你构成很重的包袱。</p>
		<h3>CMP独特的优点</h3>
		<p>　　开源以及一些数据库持久层技术崇拜者，一直抨击CMP，认为CMP慢无用，实际最大的问题是他们的设计和使用问题。</p>
		<p>　　由于EJB容器（如JBoss）对CMP实现有事务机制的缓存优化，因此，CMP特别适合多个用户同时更新同一个数据源的情况，CMP这种严格的事务完整性保证多个用户同时操作一个数据记录时，能够保证性能优化和数据的完整性，如果这个数据记录是是软件系统的状态标志，它的状态会影响系统中很多的环节，那么状态更改的重要性不言而喻。</p>
		<p>　　如果没有事务完整性支持，你的软件系统在用户访问量变大，就会变得发生各种不可能发生的逻辑错误，查看程序逻辑是正确的，那么问题出在哪里？出在数据完整性上。</p>
		<p>　　由于每个CMP在内存中都有一个缓存，在实际应用中，如果使用CMP批量读数据库数据，几万条查询完毕，内存中充满了几万条CMP缓存，如果这时你的EJB容器设置不当（如使用JBoss缺省配置），那么JVM的垃圾回收机制就会频繁启动，导致你的系统变慢甚至死机，这也是一些人抨击CMP慢的原因所在，其实他们使用方法不当，或者没有正确配置EJB容器CMP缓存。</p>
		<p>　　对于这种情况，根据J2EE核心模式，推荐使用DAO+JDBC方式。</p>
		<h3>小结</h3>
		<p>　　除非你对设计模式非常精深，能够将自己系统中的JavaBeans使用模式或某种框架进行固定分层，同时，你孜孜不倦研发出对象池，又熟练于JTA等事务机制，你可以选择没有EJB的纯Web结构，就象Jive、OFBiz那样。当然还有一个前提，老板不懂或者非常有挑战性（做与IBM SUN 微软齐名的公司和技术）。</p>
		<p>　　不要再被TSS那些狂热的开源先生误导，他们有时间有保障可以做他们喜欢的事情，作为专业的J2EE程序员，按照J2EE标准去学习去行动，也不要认为，只要使用了J2EE其中某个技术如Jsp或JavaBeans就心安理得认为自己的系统是J2EE了。</p>
		<p>　　当然，我并不是说纯Web系统不能实现多层结构，但是至少在很多方面没有Web+EJB结构完善和清晰，所以，EJB不是J2EE可以忽视的部分，而是主要的重要的部分，重要业务功能核心都封装在EJB中，相反Web层是一种次要的、和界面相关的层次。</p>
		<p>　　补充：什么情况下不需要EJB，在SUN的SECA架构师试卷中回答：小型系统和不需要事务。另外过去那种认为“EJB有性能问题”根本是一种缪误，具体可参考下面有关问题。</p>
		<h3>相关文章：</h3>
		<p>
				<a href="http://www.jdon.com/jive/article.jsp?forum=121&amp;thread=22282" target="_blank">J2EE集群原理</a>
		</p>
		<p>
				<a href="http://www.jdon.com/jive/thread.jsp?forum=16&amp;thread=22281" target="_blank">为什么需要有态Session Bean</a>
		</p>
		<p>
				<a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&amp;f=11&amp;t=006707" target="_blank">When to not use EJB </a>
		</p>
		<p>
				<a class="home_title" href="http://www.jdon.com/artichect/oo_math.htm" target="_blank">
				</a>
				<a href="http://www.jdon.com/jive/article.jsp?forum=16&amp;thread=24513" target="_blank">关于SPING与EJB的胡言乱语--重和轻永恒的话题</a>
				<br />
		</p>
		<h3>
				<a href="http://www.jdon.com/artichect/jdonframework/app.htm" target="_blank">
						<br />
				</a>
		</h3><img src ="http://www.blogjava.net/web/aggbug/68364.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-09-07 20:04 <a href="http://www.blogjava.net/web/archive/2006/09/07/why_use_EJB.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java 中的内存泄漏</title><link>http://www.blogjava.net/web/archive/2006/09/07/Leakage_of_Memory.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 07 Sep 2006 11:49:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/09/07/Leakage_of_Memory.html</guid><wfw:comment>http://www.blogjava.net/web/comments/68362.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/09/07/Leakage_of_Memory.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/68362.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/68362.html</trackback:ping><description><![CDATA[出自：ibm:developerworks中国网站 欧阳辰周欣 <br />一 问题的提出<br /><br />Java的一个重要优点就是通过垃圾收集器(Garbage Collection，GC)自动管理内存的回收，程序员不需要通过调用函数来释放内存。因此，很多程序员认为Java不存在内存泄漏问题，或者认为即使有内存泄漏也不是程序的责任，而是GC或JVM的问题。其实，这种想法是不正确的，因为Java也存在内存泄露，但它的表现与C 不同。<br /><br />随着越来越多的服务器程序采用Java技术，例如JSP，Servlet， EJB等，服务器程序往往长期运行。另外，在很多嵌入式系统中，内存的总量非常有限。内存泄露问题也就变得十分关键，即使每次运行少量泄漏，长期运行之后，系统也是面临崩溃的危险。<br /><br />二 Java是如何管理内存<br /><br />为了判断Java中是否有内存泄露，我们首先必须了解Java是如何管理内存的。Java的内存管理就是对象的分配和释放问题。在Java中，程序员需要通过关键字new为每个对象申请内存空间 (基本类型除外)，所有的对象都在堆 (Heap)中分配空间。另外，对象的释放是由GC决定和执行的。在Java中，内存的分配是由程序完成的，而内存的释放是有GC完成的，这种收支两条线的方法确实简化了程序员的工作。但同时，它也加重了JVM的工作。这也是Java程序运行速度较慢的原因之一。因为，GC为了能够正确释放对象，GC必须监控每一个对象的运行状态，包括对象的申请、引用、被引用、赋值等，GC都需要进行监控。<br /><br />监视对象状态是为了更加准确地、及时地释放对象，而释放对象的根本原则就是该对象不再被引用。<br /><br />为了更好理解GC的工作原理，我们可以将对象考虑为有向图的顶点，将引用关系考虑为图的有向边，有向边从引用者指向被引对象。另外，每个线程对象可以作为一个图的起始顶点，例如大多程序从main进程开始执行，那么该图就是以main进程顶点开始的一棵根树。在这个有向图中，根顶点可达的对象都是有效对象，GC将不回收这些对象。如果某个对象 (连通子图)与这个根顶点不可达(注意，该图为有向图)，那么我们认为这个(这些)对象不再被引用，可以被GC回收。<br /><br />以下，我们举一个例子说明如何用有向图表示内存管理。对于程序的每一个时刻，我们都有一个有向图表示JVM的内存分配情况。以下右图，就是左边程序运行到第6行的示意图。<br /><br /><br />Java使用有向图的方式进行内存管理，可以消除引用循环的问题，例如有三个对象，相互引用，只要它们和根进程不可达的，那么GC也是可以回收它们的。这种方式的优点是管理内存的精度很高，但是效率较低。另外一种常用的内存管理技术是使用计数器，例如COM模型采用计数器方式管理构件，它与有向图相比，精度行低(很难处理循环引用的问题)，但执行效率很高。<br /><br />三 什么是Java中的内存泄露<br /><br />下面，我们就可以描述什么是内存泄漏。在Java中，内存泄漏就是存在一些被分配的对象，这些对象有下面两个特点，首先，这些对象是可达的，即在有向图中，存在通路可以与其相连；其次，这些对象是无用的，即程序以后不会再使用这些对象。如果对象满足这两个条件，这些对象就可以判定为Java中的内存泄漏，这些对象不会被GC所回收，然而它却占用内存。<br /><br />在C 中，内存泄漏的范围更大一些。有些对象被分配了内存空间，然后却不可达，由于C 中没有GC，这些内存将永远收不回来。在Java中，这些不可达的对象都由GC负责回收，因此程序员不需要考虑这部分的内存泄露。<br /><br />通过分析，我们得知，对于C ，程序员需要自己管理边和顶点，而对于Java程序员只需要管理边就可以了(不需要管理顶点的释放)。通过这种方式，Java提高了编程的效率。<br /><br />因此，通过以上分析，我们知道在Java中也有内存泄漏，但范围比C 要小一些。因为Java从语言上保证，任何对象都是可达的，所有的不可达对象都由GC管理。<br /><br />对于程序员来说，GC基本是透明的，不可见的。虽然，我们只有几个函数可以访问GC，例如运行GC的函数System.gc()，但是根据Java语言规范定义， 该函数不保证JVM的垃圾收集器一定会执行。因为，不同的JVM实现者可能使用不同的算法管理GC。通常，GC的线程的优先级别较低。JVM调用GC的策略也有很多种，有的是内存使用到达一定程度时，GC才开始工作，也有定时执行的，有的是平缓执行GC，有的是中断式执行GC。但通常来说，我们不需要关心这些。除非在一些特定的场合，GC的执行影响应用程序的性能，例如对于基于Web的实时系统，如网络游戏等，用户不希望GC突然中断应用程序执行而进行垃圾回收，那么我们需要调整GC的参数，让GC能够通过平缓的方式释放内存，例如将垃圾回收分解为一系列的小步骤执行，Sun提供的HotSpot JVM就支持这一特性。<br /><br />下面给出了一个简单的内存泄露的例子。在这个例子中，我们循环申请Object对象，并将所申请的对象放入一个Vector中，如果我们仅仅释放引用本身，那么Vector仍然引用该对象，所以这个对象对GC来说是不可回收的。因此，如果对象加入到Vector后，还必须从Vector中删除，最简单的方法就是将Vector对象设置为null。<br /><br />Vector v=new Vector(10);<br />for (int i=1;i&lt;100; i )<br />{<br />Object o=new Object();<br />v.add(o);<br />o=null;<br />}<br />//此时，所有的Object对象都没有被释放，因为变量v引用这些对象。<br /><br />四 如何检测内存泄漏<br /><br />最后一个重要的问题，就是如何检测Java的内存泄漏。目前，我们通常使用一些工具来检查Java程序的内存泄漏问题。市场上已有几种专业检查Java内存泄漏的工具，它们的基本工作原理大同小异，都是通过监测Java程序运行时，所有对象的申请、释放等动作，将内存管理的所有信息进行统计、分析、可视化。开发人员将根据这些信息判断程序是否有内存泄漏问题。这些工具包括Optimizeit Profiler，JProbe Profiler，JinSight , Rational 公司的Purify等。<br /><br />下面，我们将简单介绍Optimizeit的基本功能和工作原理。<br /><br />Optimizeit Profiler版本4.11支持Application，Applet，Servlet和Romote Application四类应用，并且可以支持大多数类型的JVM，包括SUN JDK系列，IBM的JDK系列，和Jbuilder的JVM等。并且，该软件是由Java编写，因此它支持多种操作系统。Optimizeit系列还包括Thread Debugger和Code Coverage两个工具，分别用于监测运行时的线程状态和代码覆盖面。<br /><br />当设置好所有的参数了，我们就可以在OptimizeIt环境下运行被测程序，在程序运行过程中，Optimizeit可以监视内存的使用曲线(如下图)，包括JVM申请的堆(heap)的大小，和实际使用的内存大小。另外，在运行过程中，我们可以随时暂停程序的运行，甚至强行调用GC，让GC进行内存回收。通过内存使用曲线，我们可以整体了解程序使用内存的情况。这种监测对于长期运行的应用程序非常有必要，也很容易发现内存泄露。<br /><br /><br />在运行过程中，我们还可以从不同视角观查内存的使用情况，Optimizeit提供了四种方式：<br /><br />堆视角。 这是一个全面的视角，我们可以了解堆中的所有的对象信息(数量和种类)，并进行统计、排序，过滤。了解相关对象的变化情况。 <br />方法视角。通过方法视角，我们可以得知每一种类的对象，都分配在哪些方法中，以及它们的数量。 <br />对象视角。给定一个对象，通过对象视角，我们可以显示它的所有出引用和入引用对象，我们可以了解这个对象的所有引用关系。 <br />引用图。 给定一个根，通过引用图，我们可以显示从该顶点出发的所有出引用。 <br /><br />在运行过程中，我们可以随时观察内存的使用情况，通过这种方式，我们可以很快找到那些长期不被释放，并且不再使用的对象。我们通过检查这些对象的生存周期，确认其是否为内存泄露。在实践当中，寻找内存泄露是一件非常麻烦的事情，它需要程序员对整个程序的代码比较清楚，并且需要丰富的调试经验，但是这个过程对于很多关键的Java程序都是十分重要的。<br /><br />综上所述，Java也存在内存泄露问题，其原因主要是一些对象虽然不再被使用，但它们仍然被引用。为了解决这些问题，我们可以通过软件工具来检查内存泄露，检查的主要原理就是暴露出所有堆中的对象，让程序员寻找那些无用但仍被引用的对象。<br /><br />相关资源:<br /><br />文章:<br />Jim Patrick, Handling memory leaks in Java programs,<br /><a href="http://www-106.ibm.com/developerWorks/library/j-leaks/index.html" target="_blank">http://www-106.ibm.com/developerWorks/library/j-leaks/index.html</a><br />Ed Lycklama, Does Java Technology Have Memory Leaks?<br /><a href="http://www.klgroup.com/javaone" target="_blank">http://www.klgroup.com/javaone</a><br />Sun, The Java HotSpot Virtual Machine, Technical White Paper<br /><br />软件：<br />Sitraka Software's Jprobe <a href="http://www.sitraka.com/" target="_blank">http://www.sitraka.com</a><br />Boland Software's Optimizeit <a href="http://optimizeit/" target="_blank">http://optimizeit</a><br />IBM alphaWorks' Jinsight <a href="http://www.alphaworks.ibm.com/tech/jinsight" target="_blank">http://www.alphaworks.ibm.com/tech/jinsight</a><br /><br />关于作者 <br />欧阳辰，北京大学计算机硕士毕业，98年起开始研究基于java的软件开发、测试，参与开发、测试过多个基于Java的应用程序和Web服务项目。联系方式<a href="mailto:yeekee@sina.com">yeekee@sina.com</a><br />周欣，北京大学计算机系在读博士生，主要研究方向：程序理解、逆向工程及软件度量，联系方式 <a href="mailto:zhouxin@sei.pku.edu.cn">zhouxin@sei.pku.edu.cn</a><br /><br /><img src ="http://www.blogjava.net/web/aggbug/68362.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-09-07 19:49 <a href="http://www.blogjava.net/web/archive/2006/09/07/Leakage_of_Memory.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>J2EE建议的学习路线</title><link>http://www.blogjava.net/web/archive/2006/08/16/J2EE_Learning_Router.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Wed, 16 Aug 2006 09:44:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/08/16/J2EE_Learning_Router.html</guid><wfw:comment>http://www.blogjava.net/web/comments/63969.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/08/16/J2EE_Learning_Router.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/63969.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/63969.html</trackback:ping><description><![CDATA[<h1>J2EE建议的学习路线</h1>
		<div class="text">来源: <a href="http://tech.163.com/06/0509/09/2GM0OHJD0009159T.html#" target="_blank">赛迪博</a>　</div>
		<!-- main -->
		<div id="endMain">
				<div id="endText">
						<p style="TEXT-INDENT: 2em">网络上、书店都提供了很多资料，很多方式都可以得到J2EE方面的资料。如何系统的、高效的学习J2EE这个问题摆在我们面前。比如，有些人在看完一大堆书后，动起手来时还是不知道怎么开始。等等这些问题是我们最难处理的。如何寻找到一条很好的方式方法呢？</p>
						<p style="TEXT-INDENT: 2em"> </p>
						<p style="TEXT-INDENT: 2em">其实，换一个角度来看，比如，学英语，一共有三个层面的东西，首先是词汇，然后是语法，再者是习惯用法(希望读者能够从程序设计的角度考虑问题，看看这两者有什么相似之处，其实他们的逻辑是一样的)。还比如，上数学课，老师在黑板上解题，大家都很轻松得听懂，自己动手时就会有很多问题。这些看来很简单的问题，其实都包含一个道理：理论联系实际，理论指导实践。</p>
						<p style="TEXT-INDENT: 2em">我们的理论在于，我们要有很好的方法。有些人看了很多书，写了不少程序，水平还是提高得很慢，很难跨越这道难关。还是方法问题。当然，我所谈论的方法，是自己的心得，体会，大家都有自己很独特的方法。没有绝对好、绝对坏的方法，看作用对象是谁。所以这里我们重点看看我这文章中所会提出来的方法。大家来评论评论。</p>
						<p style="TEXT-INDENT: 2em">上一篇文中《走向J2EE，漫长的道路》，我谈到学习J2EE是一个漫长的过程，对，就是如此。因为她里面包含了很多全新的东西。而且，J2EE是现在进行时。我们知道J2EE由很多技术构成，比如，EJB、XML、JDBC、RMI、JSP、Servlet等等这些，又包含很多内容。无论这些具体的技术会怎么发展，怎么变化，我们要抓住主线，那就是掌握J2EE构架的精髓。用什么来分析呢，作用对象自然是J2EE Specification（最新版是1.4，http://java.sun.com/j2ee ）！！！当然学习J2EE的前提是你对J2SE有了足够的熟悉了，还有一点，你有很好的态度和兴趣。只看J2EE规范是不够的，最好结合产品和例子去思考，我建议大家用JBuilder 7 +BEA WebLogc Platform 7.0,这种开发模式。为什么这么说呢?首先，JBuilder 7本身的功能就是不错，应该属于主流Java IDE了。其次，BEA WebLogic Platform 7.0对J2EE Specification最新版支持程度很好，同时也较容易获取，用的人也多。第三，开发效率不错。（Borland网站有一份讲述JBuilder 7 + BEA WebLogic 7.0集成开发的文档，PDF格式。）</p>
						<p style="TEXT-INDENT: 2em">JBuilder 7本身提供了很多帮助文档，有PDF格式，也有HTML格式(采用JavaHelp技术制作的)，另外书店有一些JBuilder的参考用书，个人认为没有必要，第一，提供的版本都比较陈旧；第二，没有什么内容；第三，一般都是抄袭JBuilder 本身提供的帮助文档。（个人观点，没有任何商业目的）。当然，你的外语差不多要有四级水平，这个可不能没有，至少阅读能力不错（其实也不是这样的，我最开始时也是害怕，但开始投入后，英语资料也很简单，而且很地道！同时提高了您的外语）。WebLogic同样也不错,也提供了很多文档，http://www.bestdown.com 上有一本WebLogic Bible(针对6.1版)，国内的BEA公司好像也出了一本，有兴趣地可以去china pub看看。</p>
						<p style="TEXT-INDENT: 2em">有了这两者，我们需要找出合适的对象来学习。在这里给出几方面的素材给大家提供参考。</p>
						<p style="TEXT-INDENT: 2em">第一，在JBuilder 7的安装目录的这个地方，~~:\JBuilder7\samples\Ejb\Ejb20\ESiteWL，有一个很好的例子，ESite。其中用到了Session Façade设计模式，用到了JSP、Servlet、Session Beans、Entity Beans(cmp)等技术，学习过程中不懂得地方可以参考第二。</p>
						<p style="TEXT-INDENT: 2em">第二, Sun公司提供的J2EE Tutorial资料，很不错。</p>
						<p style="TEXT-INDENT: 2em">第三，Java Pet Store，刚开始学习J2EE技术分析该例子有点困难，再者这个例子中的J2EE构架不是很实用，但她给我们展示了J2EE几乎所有的核心技术，同时还提供了一本书，Design Enterprise Applications with J2EE Platform,很不错。</p>
						<p style="TEXT-INDENT: 2em">第四，对J2EE构架比较了解，对EJB,XML，JSP，Servlet等技术有了较好的理解和程序经验后，建议看看这几本书:《J2EE In Practice》、《Core J2EE Patterns》、《Sun Certified ENT Architect for J2EE - Tech Study Guide》、《Java Tools for Extreme Programming - wiley》、《EJB Design Patterns》、《MasteringEJB 2》、《Enterprise JavaBeans,3rd》,够你看得了：）。</p>
						<p style="TEXT-INDENT: 2em">有了上述基础，结合大家做项目中的一些经验，我想水平应该会有不少提高。在初步掌握上述基础后，我们每个人都可以有自己在J2EE中的定位，比如有些开发人员可以考虑把时间花在商务逻辑层、另外一些喜欢花功夫在表示层，更有贪婪的家伙花在J2EE中所有的层。还有Web Services（J2EE 1.4 Specification的重点，估计2003年初推出，今后的重要发展方向）。</p>
						<p style="TEXT-INDENT: 2em">同时，大家要注意从软件工程的角度考虑系统设计，实施，建议用用Together!!!要求大家对UML有足够的了解。</p>
				</div>
		</div><img src ="http://www.blogjava.net/web/aggbug/63969.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-08-16 17:44 <a href="http://www.blogjava.net/web/archive/2006/08/16/J2EE_Learning_Router.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts入门（转）</title><link>http://www.blogjava.net/web/archive/2006/08/16/StrutsNewComer.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Wed, 16 Aug 2006 09:39:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/08/16/StrutsNewComer.html</guid><wfw:comment>http://www.blogjava.net/web/comments/63965.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/08/16/StrutsNewComer.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/63965.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/63965.html</trackback:ping><description><![CDATA[<strong>Struts安装：<br /></strong> 首先请到http://jakarta.apache.org/Struts下载Struts，建议使用release版，现在最高版本为1.1，下载后得到的是一个ZIP文件。将ZIP包解开，可以看到这个目录：lib和webapps，webapps下有一些WAR文件。假设你的Tomcat装在c:\Tomcat下，则将那些WAR文件拷贝到C:\Tomcat\webapps，重新启动Tomcat即可。打开浏览器，在地址栏中输入：http://localhost:8080/Struts-example/index.jsp，若能见到“powered by Struts”的深蓝色图标，即说明成功了。这是Struts自带的一个例子，附有详细的说明文档，可以做为初学者的入门教程。<br />另外，Struts还提供了一系统实用对象：XML处理、通过Java reflection APIs自动处理JavaBeans属性、国际化的提示和消息等 一个实例： 一个用户注册系统，用户通过网页输入相关信息：注册ID号，密码，EMAIL，若注册成功，则返回成功提示信息，反之出现注册失败提示信息。以下是相关文件的部分核心代码。 项目建立： 正式开发前，需要在Tocmat（我的tomcat装在c:\tomcat）中建立此项目。比较快的一种建立方式为：在C:\tomcat\webapps下新建目录test，再将C:\tomcat\webapps\struts-example下的 WEB-INF目录拷贝到test目录下，然后将test\WEB-INF下的src和classes目录清空，以及struts-config.xml文件中内容清空即可。这样，我们需要的Struts类包及相关的配置文件就都齐了。 开发时，将JSP文件放在test目录下，Java原文件放在test\WEB-INF\src下，编译后的类文件放在test\WEB-INF\classes下。 注册页面：reguser.jsp <br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">&lt;%</span><span style="COLOR: #000000">@ page contentType</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">text/html;charset=UTF-8</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> language</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">java</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">%&gt;<br />&lt;%</span><span style="COLOR: #000000">@ taglib uri</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">/WEB-INF/Struts-bean.tld</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> prefix</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">bean</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">%&gt;<br />&lt;%</span><span style="COLOR: #000000">@ taglib uri</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">/WEB-INF/Struts-html.tld</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> prefix</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">html</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">%&gt;<br />&lt;?</span><span style="COLOR: #000000">XML:NAMESPACE PREFIX </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> HTML </span><span style="COLOR: #000000">/&gt;<br />&lt;</span><span style="COLOR: #000000">HTML:HTML locale</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">true</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;<br />&lt;</span><span style="COLOR: #000000">HTML:BASE</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">HTML:BASE</span><span style="COLOR: #000000">&gt;<br />&lt;</span><span style="COLOR: #000000">HTML:ERRORS</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">HTML:ERRORS</span><span style="COLOR: #000000">&gt;<br /><br />&lt;</span><span style="COLOR: #000000">HTML:FORM action</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">/regUserAction</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> focus</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">logname</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">TABLE width</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">100%</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> border</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">TBODY</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">        &lt;</span><span style="COLOR: #000000">TR</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        <span style="COLOR: #000000">        </span></span>&lt;</span><span style="COLOR: #000000">TH align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">right</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">Logname: </span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">TH</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        <span style="COLOR: #000000">        </span></span>&lt;</span><span style="COLOR: #000000">TD align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">left </span><span style="COLOR: #000000">&gt;&lt;</span><span style="COLOR: #000000">HTML:TEXT property</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">logname</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> size</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> maxlength</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">HTML:TEXT</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">TD</span><span style="COLOR: #000000">&gt;<br /><span style="COLOR: #000000">        </span>&lt;/</span><span style="COLOR: #000000">TR</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        </span>&lt;</span><span style="COLOR: #000000">TR</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        <span style="COLOR: #000000">        </span></span>&lt;</span><span style="COLOR: #000000">TH align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">right</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">Password: </span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">TH</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        <span style="COLOR: #000000">        </span></span>&lt;</span><span style="COLOR: #000000">TD align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">left</span><span style="COLOR: #000000">&gt;&lt;</span><span style="COLOR: #000000">HTML:PASSWORD property</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">password</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> size</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> maxlength</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">HTML:PASSWORD</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">TD</span><span style="COLOR: #000000">&gt;<br /><span style="COLOR: #000000">        </span>&lt;/</span><span style="COLOR: #000000">TR</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        </span>&lt;</span><span style="COLOR: #000000">TR</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        <span style="COLOR: #000000">        </span></span>&lt;</span><span style="COLOR: #000000">TH align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">right</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">E</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">mail: </span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">TH</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        <span style="COLOR: #000000">        </span></span>&lt;</span><span style="COLOR: #000000">TD align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">left</span><span style="COLOR: #000000">&gt;&lt;</span><span style="COLOR: #000000">HTML:PASSWORD property</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">email</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> size</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">30</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> maxlength</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">50</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">HTML:PASSWORD</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">TD</span><span style="COLOR: #000000">&gt;<br /><span style="COLOR: #000000">        </span>&lt;/</span><span style="COLOR: #000000">TR</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        </span>&lt;</span><span style="COLOR: #000000">TR</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        <span style="COLOR: #000000">        </span></span>&lt;</span><span style="COLOR: #000000">TD align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">middle</span><span style="COLOR: #000000">&gt;&lt;</span><span style="COLOR: #000000">HTML:SUBMIT property</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">submit</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> value</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Submit</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">HTML:SUBMIT</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">TD</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000"><span style="COLOR: #000000">        <span style="COLOR: #000000">        </span></span>&lt;</span><span style="COLOR: #000000">TD align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">left</span><span style="COLOR: #000000">&gt;&lt;</span><span style="COLOR: #000000">HTML:RESET</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">HTML:RESET</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">TD</span><span style="COLOR: #000000">&gt;<br /><span style="COLOR: #000000">        </span>&lt;/</span><span style="COLOR: #000000">TR</span><span style="COLOR: #000000">&gt;<br />&lt;/</span><span style="COLOR: #000000">TBODY</span><span style="COLOR: #000000">&gt;<br />&lt;/</span><span style="COLOR: #000000">TABLE</span><span style="COLOR: #000000">&gt;<br />&lt;/</span><span style="COLOR: #000000">HTML:FORM</span><span style="COLOR: #000000">&gt;<br />&lt;/</span><span style="COLOR: #000000">HTML:HTML</span><span style="COLOR: #000000">&gt;</span></div><br /><br /><br /><br /><br />此JSP页面不同于普通的JSP页，因为它大量运用了taglib，这些taglib对初学者而言，可能难于掌握，可这却是Struts的精华之一。灵活运用，将大大提高开发效率。 <br />Struts-config.xml： <struts-config><form-beans><form-bean name="regUserForm" type="org.cjea.Struts.example. RegUserForm " /></form-beans><action-mappings><action type=" org.cjea.Struts.example.RegUserAction " path="/regUserAction" attribute=" regUserForm " scope="request" validate="false"><forward name="failure" path="/ messageFailure.jsp" /><forward name="success" path="/ messageSuccess.jsp" /></action></action-mappings></struts-config>Struts的核心是Controller，即ActionServlet，而ActionServlet的核心就是Struts-config.xml，Struts-config.xml集中了所有页面的导航定义。对于大型的WEB项目，通过此配置文件即可迅速把握其脉络，这不管是对于前期的开发，还是后期的维护或升级都是大有裨益的。掌握Struts-config.xml是掌握Struts的关键所在。 <br />FormBean：RegUserForm <br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">package</span><span style="COLOR: #000000"> org.cjea.Struts.example;<br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> javax.Servlet.http.HttpServletRequest;<br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> org.apache.Struts.action.ActionForm; <br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> org.apache.Struts.action.ActionMapping; <br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> RegUserForm </span><span style="COLOR: #0000ff">extends</span><span style="COLOR: #000000"> ActionForm{<br />       </span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000"> String logname;<br />       </span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000"> String password;<br />       </span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000"> String email;<br />       </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> RegUserForm(){<br />               logname </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />               password </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />               email </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />       }<br />        </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> String getLogName() {<br />               </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.logname;<br />        }<br />        </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> setLogName(String logname) {<br />               </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.logname </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> logname;<br />        }<br />        </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> setPassWord(String password) {<br />               </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.password </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> password;<br />        }<br />        </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> String getPassWord() {<br />               </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.password;<br />        }<br />        </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> setEmail(String email) {<br />               </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.email </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> email;<br />        }<br />        </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> String getEmail() {<br />               </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.email; <br />       }<br />        </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> reset(ActionMapping mapping, HttpServletRequest request) {<br />               logname </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />               password </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />               email </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />        }<br /> }</span></div><br /><br />每一个FormBean 都必须继承ActionForm类，FormBean是对页面请求的封装。即把HTTP request 封装在一个对象中，需要说明的一点就是多个HTTP request可以共用一个FormBean，便于维护和重用。 ActionBean：RegUserAction<br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">package</span><span style="COLOR: #000000"> org.cjea.Struts.example;<br /> </span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> javax.Servlet.http.</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">;<br /> </span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> org.apache.Struts.action.</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">;<br /> </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> RegUserAction </span><span style="COLOR: #0000ff">extends</span><span style="COLOR: #000000"> Action {<br />         </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> ActionForward perform(ActionMapping mapping, ActionForm form, <br />                                                               HttpServletRequest req, HttpServletResponse res) {<br />                   String title </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> req.getParameter(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">title</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />                   String password </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> req.getParameter(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">password</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />                   String email </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> req.getParameter(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">email</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />                   </span><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"> 取得用户请求,做相应数据库操作，略 </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />          }<br /> } </span></div><br />FormBean的产生是为了提供数据给ActionBean，在ActionBean中可以取得FormBean中封装的数据，经相应的逻辑处理后，调用业务方法完成相应业务要求。 Servlet的演变：在常规的 JSP，Servlet，JavaBean三层结构中，JSP实现View的功能，Servlet实现Controller的功能，JavaBean实现Model的实现。 在Struts中，将常规情况下的Servlet拆分与ActionServlet、FormBean、ActionBean三个部分。ActionServlet配合Struts-config.xml，专职完成页面导航，而不再负责具体的数据获取与相应逻辑，这两部分功能由FormBean和ActionBean来完成。<br /><br /><strong> Struts优缺点<br /></strong>优点： Struts跟Tomcat、Turbine等诸多Apache项目一样，是开源软件，这是它的一大优点。使开发者能更深入的了解其内部实现机制。<br /> 除此之外，Struts的优点主要集中体现在两个方面：Taglib和页面导航。Taglib是Struts的标记库，灵活动用，能大大提高开发效率。另外，就目前国内的JSP开发者而言，除了使用JSP自带的常用标记外，很少开发自己的标记，或许Struts是一个很好的起点。 关于页面导航，我认为那将是今后的一个发展方向，事实上，这样做，使系统的脉络更加清晰。通过一个配置文件，即可把握整个系统各部分之间的联系，这对于后期的维护有着莫大的好处。尤其是当另一批开发者接手这个项目时，这种优势体现得更加明显。<br /><br />缺点： Taglib是Struts的一大优势，但对于初学者而言，却需要一个持续学习的过程，甚至还会打乱你网页编写的习惯，但是，当你习惯了它时，你会觉得它真的很棒。 Struts将MVC的Controller一分为三，在获得结构更加清晰的同时，也增加了系统的复杂度。 Struts从产生到现在还不到半年，但已逐步越来越多运用于商业软件。虽然它现在还有不少缺点，但它是一种非常优秀的J2EE MVC实现方式，如果你的系统准备采用J2EE MVC架构，那么，不妨考虑一下Struts。<br /> <br /><strong>Struts实施经验：<br /></strong> 1、基于Struts架构的项目开发，首先需要有一个很好的整体规划，整个系统中包括哪几个模块，每个模块各需要多少FormBean和ActionBean等，而且最好有专人负责Struts-config.xml的管理。开发基于Struts的项目的难点在于配置管理，尤其是对Struts-config.xml的管理<br /> 2、如果你的项目非常紧，并且项目组中又没有富有经验的Struts开发人员，建议不要冒然采用Struts。Struts的掌握需要一个过程，对于一个熟练的JSP程序员，自学大概需要半个月左右的时间。如果结合titls，则需要更长的时间<br /> 3、如果你在网页中大量运用taglib，那么你的美工将做出部分牺牲。当你结合Tiles，功能增强的同时，这种牺牲尤为明显。当然，你对功能和美观的取舍由你自己决定<br /> 4、Taglib是一个好东西，但灵活运用它却需要一个过程，如果你不想在Taglib上花太多的时间，那么只需理解与FORM有关的几个标记，其它的标记就放着吧，以后再看，先去研究ActionServlet和Struts-config.xml，你会觉得很有成就感<br /> 5、Struts是否只适合于大型项目呢？No！Struts适合于各种大小的项目，当然，对于大型项目，它所体现出来的优势更加明显。<img src ="http://www.blogjava.net/web/aggbug/63965.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-08-16 17:39 <a href="http://www.blogjava.net/web/archive/2006/08/16/StrutsNewComer.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts安装配置(转)</title><link>http://www.blogjava.net/web/archive/2006/08/16/StrutsSetup.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Wed, 16 Aug 2006 09:11:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/08/16/StrutsSetup.html</guid><wfw:comment>http://www.blogjava.net/web/comments/63953.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/08/16/StrutsSetup.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/63953.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/63953.html</trackback:ping><description><![CDATA[<div class="postText">
				<p>Struts安装配置 </p>
				<p>1、Struts的安装比较简单，下面的以Tomcat 4.1.24为例，讲述安装过程。 首先请到http://jakarta.apache.org/Struts下载Struts，建议使用release版，现在最高版本为1.1，下载后得到的是一个ZIP文件。 将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属性、国际化的提示和消息等 </p>
				<p>2、关于Struts配置，由于我是采用Jbuilder9为开发工具，这里主要说一下Struts在Jbuilder中配置：Jbuilder本身自带已经集成了Struts1.0，但目前的开发大部分都是在Struts1.1下，所以下面就介绍Struts1.1在Jbuilder中的配置： </p>
				<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
						<p>1、下载 jakarta-struts-1.1.zip 包；jakarta-struts-1.1-src.zip包 </p>
						<p>2、将jakarta-struts-1.1.zip包解压到C:\JBuilder9\thirdparty目录下 jakarta-struts-1.1-src.zip包解压到C:\JBuilder9\extras目录下 </p>
						<p>3、启动jbuilder9 </p>
						<p>4、配置Library （1）选择菜单 tools\Configure Libraries （2）新建一个Library （3）在New Library Wizard对话框中， Name 输入：struts1.1， location可选：User Home， Library paths：add加入C:\JBuilder9\thirdparty\jakarta-struts-1.1\lib\struts.jar （4）确定创建Library （5）选中struts1.1，修改Library Settings Class：C:\JBuilder9\thirdparty\jakarta-struts-1.1\lib\struts.jar Source：C:\JBuilder9\extras\jakarta-struts-1.1-src\src\share DocumentationC:\JBuilder9\thirdparty\jakarta-struts-1.1\webapps\struts-documentation.war\api Required Library：空 Framework：在Framework下拉框中，选择struts，会自动出现6个taglib。 struts-bean struts-html struts-logic struts-template struts-tiles struts-nested （6）点击OK，创建Library成功。 </p>
				</blockquote>
				<p dir="ltr">关于在其他工具上的配置，如Eclipse 网上有很多资料。 </p>
		</div><img src ="http://www.blogjava.net/web/aggbug/63953.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-08-16 17:11 <a href="http://www.blogjava.net/web/archive/2006/08/16/StrutsSetup.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>文件或文件夹拷贝（源代码）</title><link>http://www.blogjava.net/web/archive/2006/08/10/IOFileCopyCode.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 10 Aug 2006 15:41:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/08/10/IOFileCopyCode.html</guid><wfw:comment>http://www.blogjava.net/web/comments/62884.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/08/10/IOFileCopyCode.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/62884.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/62884.html</trackback:ping><description><![CDATA[<p>
				<font color="#ff0000">本人原创，转载请注明出处</font>：<a href="/web/">http://www.blogjava.net/web/</a></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">任务：<br /></span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">写一个文件拷贝函数： fileCopy(String a ,String b)   <br /></span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">a--表示原文件名   b--表示目标文件名扩展：<br /></span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">如果a是文件，则copy a到b ;<br /></span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">如果a是目录，则copy a下的所有文件和文件夹（包括子文件夹）到b目录下。<br /></span>
				<span style="COLOR: #008000">//<br /></span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.io.</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">;<br /><br /><br /></span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> IODemo {<br />    <br />    </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> fileCopy(String a, String b){<br />        File file </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> File(a);<br /><br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">!</span>
				<span style="COLOR: #000000">file.exists()){<br />            System.out.println(a </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> Not Exists.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />            </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000">;<br />        }<br />        File fileb </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> File(b);<br /><br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(file.isFile()){<br />            FileInputStream fis </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">;<br />            FileOutputStream fos </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">;<br />            </span>
				<span style="COLOR: #0000ff">try</span>
				<span style="COLOR: #000000"> {<br />                fis </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> FileInputStream(file);<br />                fos </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> FileOutputStream(fileb);<br />                <br />                </span>
				<span style="COLOR: #0000ff">byte</span>
				<span style="COLOR: #000000">[] bb </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">byte</span>
				<span style="COLOR: #000000">[ (</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">)file.length()];<br />                fis.read(bb);<br />                fos.write(bb);<br /><br />            }</span>
				<span style="COLOR: #0000ff">catch</span>
				<span style="COLOR: #000000"> (IOException e){<br />                e.printStackTrace();<br />            }</span>
				<span style="COLOR: #0000ff">finally</span>
				<span style="COLOR: #000000">{<br />                </span>
				<span style="COLOR: #0000ff">try</span>
				<span style="COLOR: #000000"> {<br />                    fis.close();<br />                    fos.close();<br />                } </span>
				<span style="COLOR: #0000ff">catch</span>
				<span style="COLOR: #000000"> (IOException e) {<br />                    e.printStackTrace();<br />                }<br />            }<br />        }</span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(file.isDirectory()){<br />            </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">!</span>
				<span style="COLOR: #000000">fileb.exists()){<br />                fileb.mkdir();<br />            }<br />            String[] fileList;<br />            fileList </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> file.list();<br />            </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; i </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> fileList.length; i</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">){<br />                fileCopy(a </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">\\</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> fileList[i],b </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">\\</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> fileList[i]);<br />            }<br />        }<br /><br />    }<br />    <br />}<br /></span>
		</div><img src ="http://www.blogjava.net/web/aggbug/62884.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-08-10 23:41 <a href="http://www.blogjava.net/web/archive/2006/08/10/IOFileCopyCode.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jsp生成随机验证码图片（转）</title><link>http://www.blogjava.net/web/archive/2006/08/06/jspCreateRandPic.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Sun, 06 Aug 2006 13:45:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/08/06/jspCreateRandPic.html</guid><wfw:comment>http://www.blogjava.net/web/comments/62081.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/08/06/jspCreateRandPic.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/62081.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/62081.html</trackback:ping><description><![CDATA[转自：<a href="http://www.matrix.org.cn/resource/article/0/910.html">http://www.matrix.org.cn/resource/article/0/910.html</a><br /><br /><br />生成有4个随机数字和杂乱背景的图片，数字和背景颜色会改变，服务器端刷新（用history.go(-1)也会变）<br />原型参考ALIBABA  <a href="http://china.alibaba.com/member/showimage" target="_blank">http://china.alibaba.com/member/showimage</a><br /><br />------------产生验证码图片的文件-----image.jsp-------------------------------------------<br /><br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">&lt;%</span><span style="COLOR: #000000">@ page contentType</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">image/jpeg</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> import</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">%&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;%!</span><span style="COLOR: #000000"><br />Color getRandColor(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> fc,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> bc){</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">给定范围获得随机颜色</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">        Random random </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Random();<br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(fc</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">255</span><span style="COLOR: #000000">) fc</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">255</span><span style="COLOR: #000000">;<br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(bc</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">255</span><span style="COLOR: #000000">) bc</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">255</span><span style="COLOR: #000000">;<br />        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> r</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">fc</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">random.nextInt(bc</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">fc);<br />        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> g</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">fc</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">random.nextInt(bc</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">fc);<br />        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> b</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">fc</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">random.nextInt(bc</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">fc);<br />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Color(r,g,b);<br />        }<br /></span><span style="COLOR: #000000">%&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;%</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">设置页面不缓存</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">response.setHeader(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Pragma</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">No-cache</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />response.setHeader(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Cache-Control</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">no-cache</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />response.setDateHeader(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Expires</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);<br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 在内存中创建图象</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> width</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">60</span><span style="COLOR: #000000">, height</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">;<br />BufferedImage image </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);<br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 获取图形上下文</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">Graphics g </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> image.getGraphics();<br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">生成随机类</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">Random random </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Random();<br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 设定背景色</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">g.setColor(getRandColor(</span><span style="COLOR: #000000">200</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">250</span><span style="COLOR: #000000">));<br />g.fillRect(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, width, height);<br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">设定字体</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">g.setFont(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Font(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Times New Roman</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,Font.PLAIN,</span><span style="COLOR: #000000">18</span><span style="COLOR: #000000">));<br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">画边框</span><span style="COLOR: #008000"><br />//</span><span style="COLOR: #008000">g.setColor(new Color());</span><span style="COLOR: #008000"><br />//</span><span style="COLOR: #008000">g.drawRect(0,0,width-1,height-1);</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000"><br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 随机产生155条干扰线，使图象中的认证码不易被其它程序探测到</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">g.setColor(getRandColor(</span><span style="COLOR: #000000">160</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">200</span><span style="COLOR: #000000">));<br /></span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">155</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br />{<br />        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> x </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> random.nextInt(width);<br />        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> y </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> random.nextInt(height);<br />        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> xl </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> random.nextInt(</span><span style="COLOR: #000000">12</span><span style="COLOR: #000000">);<br />        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> yl </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> random.nextInt(</span><span style="COLOR: #000000">12</span><span style="COLOR: #000000">);<br />        g.drawLine(x,y,x</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">xl,y</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">yl);<br />}<br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 取随机产生的认证码(4位数字)</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">String sRand</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">){<br />    String rand</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">String.valueOf(random.nextInt(</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">));<br />    sRand</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">rand;<br />    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 将认证码显示到图象中</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">    g.setColor(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Color(</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">random.nextInt(</span><span style="COLOR: #000000">110</span><span style="COLOR: #000000">),</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">random.nextInt(</span><span style="COLOR: #000000">110</span><span style="COLOR: #000000">),</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">random.nextInt(</span><span style="COLOR: #000000">110</span><span style="COLOR: #000000">)));</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">调用函数出来的颜色相同，可能是因为种子太接近，所以只能直接生成</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">    g.drawString(rand,</span><span style="COLOR: #000000">13</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">16</span><span style="COLOR: #000000">);<br />}<br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 将认证码存入SESSION</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">session.setAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">rand</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,sRand);<br /><br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 图象生效</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">g.dispose();<br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 输出图象到页面</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">ImageIO.write(image, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">JPEG</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, response.getOutputStream());<br /><br /><br /></span><span style="COLOR: #000000">%&gt;</span><span style="COLOR: #000000"> <br /></span></div><br />---------------使用验证码图片的文件---------a.jsp------------------------------------<br /><br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">&lt;%</span><span style="COLOR: #000000">@ page contentType</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">text/html;charset=gb2312</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">%&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;!</span><span style="COLOR: #000000">DOCTYPE HTML PUBLIC </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">-//W3C//DTD HTML 4.01 Transitional//EN</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">html</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">head</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">title</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">认证码输入页面</span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">title</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">meta http</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">equiv</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Content-Type</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> content</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">text/html; charset=gb2312</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">META HTTP</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">EQUIV</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Pragma</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> CONTENT</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">no-cache</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">META HTTP</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">EQUIV</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Cache-Control</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> CONTENT</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">no-cache</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">META HTTP</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">EQUIV</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Expires</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> CONTENT</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">head</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">body</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">form method</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">post action</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">check.jsp</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">table</span><span style="COLOR: #000000">&gt;<br /></span><span style="COLOR: #000000">    &lt;</span><span style="COLOR: #000000">tr</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">td align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">left</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">系统产生的认证码：</span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">td</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">td</span><span style="COLOR: #000000">&gt;&lt;</span><span style="COLOR: #000000">img border</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"> src</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">image.jsp</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">td</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">tr</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">tr</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">td align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">left</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">输入上面的认证码：</span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">td</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">td</span><span style="COLOR: #000000">&gt;&lt;</span><span style="COLOR: #000000">input type</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">text name</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">rand maxlength</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000"> value</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">td</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">tr</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">tr</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">td colspan</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"> align</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">center</span><span style="COLOR: #000000">&gt;&lt;</span><span style="COLOR: #000000">input type</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">submit value</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">提交检测</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">td</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />     </span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">tr</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">table</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">form</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">body</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">html</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span></div><br /><br />-----------------验证的页面----------check.jsp<br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">&lt;%</span><span style="COLOR: #000000">@ page contentType</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">text/html; charset=gb2312</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> language</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">java</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">java.sql.*</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> errorPage</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">%&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">html</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">head</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">title</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">认证码验证页面</span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">title</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">meta http</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">equiv</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Content-Type</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> content</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">text/html; charset=gb2312</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">META HTTP</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">EQUIV</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Pragma</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> CONTENT</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">no-cache</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">META HTTP</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">EQUIV</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Cache-Control</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> CONTENT</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">no-cache</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">META HTTP</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">EQUIV</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Expires</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> CONTENT</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">head</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">body</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;%</span><span style="COLOR: #000000"> <br />String rand </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (String)session.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">rand</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />String input </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> request.getParameter(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">rand</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #000000">%&gt;</span><span style="COLOR: #000000"><br />系统产生的认证码为： </span><span style="COLOR: #000000">&lt;%=</span><span style="COLOR: #000000"> rand </span><span style="COLOR: #000000">%&gt;&lt;</span><span style="COLOR: #000000">br</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br />您输入的认证码为： </span><span style="COLOR: #000000">&lt;%=</span><span style="COLOR: #000000"> input </span><span style="COLOR: #000000">%&gt;&lt;</span><span style="COLOR: #000000">br</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">br</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;%</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (rand.equals(input)) {<br /></span><span style="COLOR: #000000">%&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">font color</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">green</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">输入相同，认证成功！</span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">font</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;%</span><span style="COLOR: #000000"><br />  } </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> {<br /></span><span style="COLOR: #000000">%&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">font color</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">red</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">输入不同，认证失败！</span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">font</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;%</span><span style="COLOR: #000000"><br />  }<br /></span><span style="COLOR: #000000">%&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">body</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">html</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span></div><br /><img src ="http://www.blogjava.net/web/aggbug/62081.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-08-06 21:45 <a href="http://www.blogjava.net/web/archive/2006/08/06/jspCreateRandPic.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>什么是3G?详解（转）</title><link>http://www.blogjava.net/web/archive/2006/07/29/WhatIs3G.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Sat, 29 Jul 2006 00:57:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/29/WhatIs3G.html</guid><wfw:comment>http://www.blogjava.net/web/comments/60686.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/29/WhatIs3G.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/60686.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/60686.html</trackback:ping><description><![CDATA[<font color="#006699">3G是英文3rdGeneration 的缩写，指第三代移动通信技术。相对第一代模拟<br />制式手机（1G）和第二代GSM 、TDMA等数字手机（2G），第三代手机一般地讲，<br />是指将无线通信与国际互联网等多媒体通信结合的新一代移动通信系统。它能够<br />处理图像、音乐、视频流等多种媒体形式，提供包括网页浏览、电话会议、电子<br />商务等多种信息服务。为了提供这种服务，无线网络必须能够支持不同的数据传<br />输速度，也就是说在室内、室外和行车的环境中能够分别支持至少2Mbps （兆字<br />节／每秒？84kbps（千字节／每秒）以及144kbps 的传输速度。</font>
		<p>
				<font color="#006699">    3G的技术标准</font>
		</p>
		<p>
				<font color="#006699">    国际电信联盟（ITU ）在2000年5 月确定W —CDMA、CDMA2000和TDS —CDMA<br />三大主流无线接口标准，写入3G技术指导性文件《2000年国际移动通讯计划》<br />（简称IMT —2000）。</font>
		</p>
		<p>
				<font color="#006699">    W —CDMA</font>
		</p>
		<p>
				<font color="#006699">    即WidebandCDMA，也称为CDMADirectSpread，意为宽频分码多重存取，其支<br />持者主要是以GSM 系统为主的欧洲厂商，日本公司也或多或少参与其中，包括欧<br />美的爱立信、阿尔卡特、*** 、朗讯、北电，以及日本的NTT 、富士通、夏普等<br />厂商。这套系统能够架设在现有的GSM 网络上，对于系统提供商而言可以较轻易<br />地过渡，而GSM 系统相当普及的亚洲对这套新技术的接受度预料会相当高。因此<br />W —CDMA具有先天的市场优势。</font>
		</p>
		<p>
				<font color="#006699">    CDMA2000</font>
		</p>
		<p>
				<font color="#006699">    CDMA2000也称为CDMAMulti —Carrier ，由美国高通北美公司为主导提出，<br />摩托罗拉、Lucent和后来加入的韩国*** 都有参与，韩国现在成为该标准的主导<br />者。这套系统是从窄频CDMAOne 数字标准衍生出来的，可以从原有的CDMAOne 结<br />构直接升级到3G，建设成本低廉。但目前使用CDMA的地区只有日、韩和北美，所<br />以CDMA2000的支持者不如W —CDMA多。不过CDMA2000的研发技术却是目前各标准<br />中进度最快的，许多3G手机已经率先面世。</font>
		</p>
		<p>
				<font color="#006699">    TD—SCDMA</font>
		</p>
		<p>
				<font color="#006699">    该标准是由中国大陆独自制定的3G标准，1999年6 月29日，中国原邮电部电<br />信科学技术研究院（大唐电信）向ITU 提出。该标准将智能无线、同步CDMA和软<br />件无线电等当今国际领先技术融于其中，在频谱利用率、对业务支持具有灵活性、<br />频率灵活性及成本等方面的独特优势。另外，由于中国内的庞大的市场，该标准<br />受到各大主要电信设备厂商的重视，全球一半以上的设备厂商都宣布可以支持TD<br />—SCDMA 标准。</font>
		</p>
		<p>
				<font color="#006699">    什么是2.5G</font>
		</p>
		<p>
				<font color="#006699">    目前已经进行商业应用的2.5G移动通信技术是从2G迈向3G的衔接性技术，由<br />于3G是个相当浩大的工程，所牵扯的层面多且复杂，要从目前的2G迈向3G不可能<br />一下就衔接得上，因此出现了介于2G和3G之间的2.5G.HSCSD、WAP 、EDGE、蓝牙<br />（Bluetooth ）、EPOC等技术都是2.5G技术。</font>
		</p>
		<p>
				<font color="#006699">    HSCSD （高速电路交换数据服务）</font>
		</p>
		<p>
				<font color="#006699">    这是GSM 网络的升级版本，HSCSD （HighSpeedCircuitSwitchedData）能够<br />透过多重时分同时进行传输，而不是只有单一时分而已，因此能够将传输速度大<br />幅提升到平常的二至三倍。目前新加坡M1与新加坡电讯的移动电话都采用HSCSD<br />系统，其传输速度能够达到57.6kbps.</font>
		</p>
		<p>
				<font color="#006699">    WAP （无线应用通讯协议）</font>
		</p>
		<p>
				<font color="#006699">    WAP （WirelessApplicationProtocol ）是移动通信与互联网结合的第一阶<br />段性产物。这项技术让使用者可以用手机之类的无线装置上网，透过小型屏幕遨<br />游在各个网站之间。而这些网站也必须以WML （无线标记语言）编写，相当于国<br />际互联网上的HTML（超文件标记语言）。</font>
		</p>
		<p>
				<font color="#006699">    Bluetooth （蓝牙）</font>
		</p>
		<p>
				<font color="#006699">    蓝牙是一种短距的无线通讯技术，电子装置彼此可以透过蓝牙而连接起来，<br />传统的电线在这里就毫无用武之地了。透过芯片上的无线接收器，配有蓝牙技术<br />的电子产品能够在十公尺的距离内彼此相通，传输速度可以达到每秒钟1 兆字节。<br />以往红外线接口的传输技术需要电子装置在视线之内的距离，而现在有了蓝牙技<br />术，这样的麻烦也可以免除了。</font>
		</p>
		<p>
				<font color="#006699">    3G何时到来</font>
		</p>
		<p>
				<font color="#006699">    日本移动通讯巨人NTTDoCoMo 已于10月1 日开通全球第一个3G服务，该服务<br />基于WCDMA 标准。</font>
		</p>
		<p>
				<font color="#006699">    目前，亚洲成为3G发展最快的地区，欧洲紧随其次，美国由于不太热心而在<br />技术准备上远远落后。除了动作最快的日本和韩国，泰国、香港也已经发出3G牌<br />照。台湾即将发放3G牌照，预计内地在年底前发出3G牌照，市场预期将发行两到<br />三个牌照</font>
				<br />
		</p><img src ="http://www.blogjava.net/web/aggbug/60686.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-29 08:57 <a href="http://www.blogjava.net/web/archive/2006/07/29/WhatIs3G.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>什么是数据仓库(转)</title><link>http://www.blogjava.net/web/archive/2006/07/24/database_warehouse.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Mon, 24 Jul 2006 06:01:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/24/database_warehouse.html</guid><wfw:comment>http://www.blogjava.net/web/comments/59792.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/24/database_warehouse.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/59792.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/59792.html</trackback:ping><description><![CDATA[<center>
				<h4>什么是数据仓库</h4>
		</center>
		<br />(转载自北大高科网站，http://www.pku-ht.com/) <br /><br />    目前，数据仓库一词尚没有一个统一的定义，著名的数据仓库专家W.H.Inmon在其著作《Building the Data Warehouse》一书中给予如下描述：数据仓库（Data Warehouse）是一个面向主题的（Subject Oriented）、集成的（Integrate）、相对稳定的（Non-Volatile）、反映历史变化（Time Variant）的数据集合，用于支持管理决策。对于数据仓库的概念我们可以从两个层次予以理解，首先，数据仓库用于支持决策，面向分析型数据处理，它不同于企业现有的操作型数据库；其次，数据仓库是对多个异构的数据源有效集成，集成后按照主题进行了重组，并包含历史数据，而且存放在数据仓库中的数据一般不再修改。<br /><br />    根据数据仓库概念的含义，数据仓库拥有以下四个特点：<br />     1、面向主题。操作型数据库的数据组织面向事务处理任务，各个业务系统之间各自分离，而数据仓库中的数据是按照一定的主题域进行组织。主题是一个抽象的概念，是指用户使用数据仓库进行决策时所关心的重点方面，一个主题通常与多个操作型信息系统相关。<br /><br />     2、集成的。面向事务处理的操作型数据库通常与某些特定的应用相关，数据库之间相互独立，并且往往是异构的。而数据仓库中的数据是在对原有分散的数据库数据抽取、清理的基础上经过系统加工、汇总和整理得到的，必须消除源数据中的不一致性，以保证数据仓库内的信息是关于整个企业的一致的全局信息。 <br /><br />     3、相对稳定的。操作型数据库中的数据通常实时更新，数据根据需要及时发生变化。数据仓库的数据主要供企业决策分析之用，所涉及的数据操作主要是数据查询，一旦某个数据进入数据仓库以后，一般情况下将被长期保留，也就是数据仓库中一般有大量的查询操作，但修改和删除操作很少，通常只需要定期的加载、刷新。<br /><br />     4、反映历史变化。操作型数据库主要关心当前某一个时间段内的数据，而数据仓库中的数据通常包含历史信息，系统记录了企业从过去某一时点(如开始应用数据仓库的时点)到目前的各个阶段的信息，通过这些信息，可以对企业的发展历程和未来趋势做出定量分析和预测。<br />企业数据仓库的建设，是以现有企业业务系统和大量业务数据的积累为基础。数据仓库不是静态的概念，只有把信息及时交给需要这些信息的使用者，供他们做出改善其业务经营的决策，信息才能发挥作用，信息才有意义。而把信息加以整理归纳和重组，并及时提供给相应的管理决策人员，是数据仓库的根本任务。因此，从产业界的角度看，数据仓库建设是一个工程，是一个过程。<br />整个数据仓库系统是一个包含四个层次的体系结构，具体由下图表示。 <br /><br /><p></p><td></td><tr><td height="91"></td><td colspan="3" valign="top"><table cellspacing="0" cellpadding="0" width="100%" border="0"><tbody><tr><td width="661" height="91"><div align="center"><img src="http://www.huihoo.com/database/i/a1.jpg" /><br />数据仓库系统体系结构 </div></td></tr></tbody></table></td><td></td></tr><tr><table cellspacing="0" cellpadding="0" width="760" align="center" border="0"><tbody><tr><td class="b1" width="100%" height="134"><br />·数据源：是数据仓库系统的基础，是整个系统的数据源泉。通常包括企业内部信息和外部信息。内部信息包括存放于RDBMS中的各种业务处理数据和各类文档数据。外部信息包括各类法律法规、市场信息和竞争对手的信息等等；<br /><br />·数据的存储与管理：是整个数据仓库系统的核心。数据仓库的真正关键是数据的存储和管理。数据仓库的组织管理方式决定了它有别于传统数据库，同时也决定了其对外部数据的表现形式。要决定采用什么产品和技术来建立数据仓库的核心，则需要从数据仓库的技术特点着手分析。针对现有各业务系统的数据，进行抽取、清理，并有效集成，按照主题进行组织。数据仓库按照数据的覆盖范围可以分为企业级数据仓库和部门级数据仓库（通常称为数据集市）。 <br /><br />·OLAP服务器：对分析需要的数据进行有效集成，按多维模型予以组织，以便进行多角度、多层次的分析，并发现趋势。其具体实现可以分为：ROLAP、MOLAP和HOLAP。ROLAP基本数据和聚合数据均存放在RDBMS之中；MOLAP基本数据和聚合数据均存放于多维数据库中；HOLAP基本数据存放于RDBMS之中，聚合数据存放于多维数据库中。<br /><br />·前端工具：主要包括各种报表工具、查询工具、数据分析工具、数据挖掘工具以及各种基于数据仓库或数据集市的应用开发工具。其中数据分析工具主要针对OLAP服务器，报表工具、数据挖掘工具主要针对数据仓库。<br /></td></tr></tbody></table></tr><img src ="http://www.blogjava.net/web/aggbug/59792.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-24 14:01 <a href="http://www.blogjava.net/web/archive/2006/07/24/database_warehouse.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>官方Class LookupDispatchAction说明文档（转）</title><link>http://www.blogjava.net/web/archive/2006/07/20/Class_LookupDispatchAction_HTMLHelp.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 20 Jul 2006 10:18:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/20/Class_LookupDispatchAction_HTMLHelp.html</guid><wfw:comment>http://www.blogjava.net/web/comments/59275.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/20/Class_LookupDispatchAction_HTMLHelp.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/59275.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/59275.html</trackback:ping><description><![CDATA[<table cellspacing="0" cellpadding="1" width="100%" summary="" border="0">
				<tbody>
						<tr>
								<td class="NavBarCell1" bgcolor="#eeeeff" colspan="3">
										<a target="_blank" rel="nofollow" name="navbar_top_firstrow">
												<!-- -->
										</a>
										<table cellspacing="3" cellpadding="0" summary="" border="0">
												<tbody>
														<tr valign="top" align="middle">
																<td class="NavBarCell1" bgcolor="#eeeeff">
																		<a href="http://struts.apache.org/api/overview-summary.html" target="_blank" rel="nofollow">
																				<font class="NavBarFont1" color="#00768a">
																						<b>Overview</b>
																				</font>
																		</a> </td>
																<td class="NavBarCell1" bgcolor="#eeeeff">
																		<a href="http://struts.apache.org/api/org/apache/struts/actions/package-summary.html" target="_blank" rel="nofollow">
																				<font class="NavBarFont1" color="#00768a">
																						<b>Package</b>
																				</font>
																		</a> </td>
																<td class="NavBarCell1Rev" bgcolor="#ffffff"> <font class="NavBarFont1Rev"><b>Class</b></font> </td>
																<td class="NavBarCell1" bgcolor="#eeeeff">
																		<a href="http://struts.apache.org/api/org/apache/struts/actions/class-use/LookupDispatchAction.html" target="_blank" rel="nofollow">
																				<font class="NavBarFont1" color="#00768a">
																						<b>Use</b>
																				</font>
																		</a> </td>
																<td class="NavBarCell1" bgcolor="#eeeeff">
																		<a href="http://struts.apache.org/api/org/apache/struts/actions/package-tree.html" target="_blank" rel="nofollow">
																				<font class="NavBarFont1" color="#00768a">
																						<b>Tree</b>
																				</font>
																		</a> </td>
																<td class="NavBarCell1" bgcolor="#eeeeff">
																		<a href="http://struts.apache.org/api/deprecated-list.html" target="_blank" rel="nofollow">
																				<font class="NavBarFont1" color="#00768a">
																						<b>Deprecated</b>
																				</font>
																		</a> </td>
																<td class="NavBarCell1" bgcolor="#eeeeff">
																		<a href="http://struts.apache.org/api/index-all.html" target="_blank" rel="nofollow">
																				<font class="NavBarFont1" color="#00768a">
																						<b>Index</b>
																				</font>
																		</a> </td>
																<td class="NavBarCell1" bgcolor="#eeeeff">
																		<a href="http://struts.apache.org/api/help-doc.html" target="_blank" rel="nofollow">
																				<font class="NavBarFont1" color="#00768a">
																						<b>Help</b>
																				</font>
																		</a> </td>
														</tr>
												</tbody>
										</table>
								</td>
								<td valign="top" align="right" rowspan="3">
										<em>
										</em>
								</td>
						</tr>
						<tr>
								<td class="NavBarCell2" bgcolor="white">
										<font size="-2"> <a title="class in org.apache.struts.actions" href="http://struts.apache.org/api/org/apache/struts/actions/LocaleAction.html" target="_blank" rel="nofollow"><b><font color="#00768a">PREV CLASS</font></b></a>   <a title="class in org.apache.struts.actions" href="http://struts.apache.org/api/org/apache/struts/actions/MappingDispatchAction.html" target="_blank" rel="nofollow"><b><font color="#00768a">NEXT CLASS</font></b></a></font>
								</td>
								<td class="NavBarCell2" bgcolor="white">
										<font size="-2">
												<a href="http://struts.apache.org/api/index.html" target="_blank" rel="nofollow">
														<b>
																<font color="#00768a">FRAMES</font>
														</b>
												</a>    <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html" target="_blank" rel="nofollow"><b><font color="#00768a">NO FRAMES</font></b></a>     <!--  if(window==top) {    document.writeln('<a target="_blank" rel="nofollow" HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');  }  //--><a href="http://struts.apache.org/api/allclasses-noframe.html" target="_blank" rel="nofollow"><b><font color="#00768a">All Classes</font></b></a><a href="http://www.nimoblog.cn/allclasses-noframe.html" target="_blank" rel="nofollow"><b><font color="#00768a">All Classes</font></b></a></font>
								</td>
						</tr>
						<tr>
								<td class="NavBarCell3" valign="top">
										<font size="-2">SUMMARY: NESTED | <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#field_summary" target="_blank" rel="nofollow"><font color="#00768a">FIELD</font></a> | <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#constructor_summary" target="_blank" rel="nofollow"><font color="#00768a">CONSTR</font></a> | <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#method_summary" target="_blank" rel="nofollow"><font color="#00768a">METHOD</font></a></font>
								</td>
								<td class="NavBarCell3" valign="top">
										<font size="-2">DETAIL: <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#field_detail" target="_blank" rel="nofollow"><font color="#00768a">FIELD</font></a> | <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#constructor_detail" target="_blank" rel="nofollow"><font color="#00768a">CONSTR</font></a> | <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#method_detail" target="_blank" rel="nofollow"><font color="#00768a">METHOD</font></a></font>
								</td>
						</tr>
				</tbody>
		</table>
		<a target="_blank" rel="nofollow" name="skip-navbar_top">
		</a>
		<!-- ========= END OF TOP NAVBAR ========= -->
		<font color="#00768a">
				<hr />
				<!-- ======== START OF CLASS DATA ======== -->
		</font>
		<h2>
				<font size="-1">org.apache.struts.actions</font>
				<br />
				<script type="text/javascript">
						<!--



























google_ad_client = "pub-0139896083561460";



























google_ad_width = 336;



























google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text";
google_ad_channel ="";



























google_color_border = "870100";
google_color_bg = "FFFFFF";
google_color_link = "0033FF";
google_color_url = "999999";
google_color_text = "FF0099";



























//-->
				</script>
				<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
				</script>
				<br />Class LookupDispatchAction</h2>
		<br />
		<script type="text/javascript">
				<!--



























google_ad_client = "pub-0139896083561460";



























google_ad_width = 336;



























google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text";
google_ad_channel ="";



























google_color_border = "870100";
google_color_bg = "FFFFFF";
google_color_link = "0033FF";
google_color_url = "999999";
google_color_text = "FF0099";



























//-->
		</script>
		<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
		</script>
		<br />java.lang.Object <img alt="extended by" src="http://struts.apache.org/api/resources/inherit.gif" /><a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/Action.html" target="_blank" rel="nofollow"><font color="#00768a">org.apache.struts.action.Action</font></a><img alt="extended by" src="http://struts.apache.org/api/resources/inherit.gif" /><a title="class in org.apache.struts.actions" href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html" target="_blank" rel="nofollow"><font color="#00768a">org.apache.struts.actions.DispatchAction</font></a><img alt="extended by" src="http://struts.apache.org/api/resources/inherit.gif" /><b>org.apache.struts.actions.LookupDispatchAction</b><pre></pre><hr /><dl><dt>public abstract class <b>LookupDispatchAction</b></dt><dt>extends <a title="class in org.apache.struts.actions" href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html" target="_blank" rel="nofollow"><font color="#00768a">DispatchAction</font></a></dt></dl><br /><script type="text/javascript"><!--



























google_ad_client = "pub-0139896083561460";



























google_ad_width = 336;



























google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text";
google_ad_channel ="";



























google_color_border = "870100";
google_color_bg = "FFFFFF";
google_color_link = "0033FF";
google_color_url = "999999";
google_color_text = "FF0099";



























//--></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script><br />An abstract <strong>Action</strong> that dispatches to the subclass mapped <code>execute</code> method. This is useful in cases where an HTML form has multiple submit buttons with the same name. The button name is specified by the <code>parameter</code> property of the corresponding ActionMapping. To configure the use of this action in your <code>struts-config.xml</code> file, create an entry like this: 
<p></p><pre>   &lt;action path="/test"<br />      type="org.example.MyAction" <br />      name="MyForm" <br />      scope="request"<br />      input="/test.jsp"<br />      parameter="method"/&gt; </pre><p>which will use the value of the request parameter named "method" to locate the corresponding key in ApplicationResources. For example, you might have the following ApplicationResources.properties:</p><pre>    button.add=Add Record    button.delete=Delete Record  </pre><p>And your JSP would have the following format for submit buttons:</p><pre>   &lt;html:form action="/test"&gt;<br />   &lt;html:submit property="method"&gt;<br />      &lt;bean:message key="button.add"/&gt;  <br />  &lt;/html:submit&gt;    <br />&lt;html:submit property="method"&gt;      <br />   &lt;bean:message key="button.delete"/&gt;    <br />&lt;/html:submit&gt;  &lt;/html:form&gt;  </pre><p>Your subclass must implement both getKeyMethodMap and the methods defined in the map. An example of such implementations are:</p><pre>  protected Map getKeyMethodMap() {<br />      Map map = new HashMap();<br />      map.put("button.add", "add");<br />      map.put("button.delete", "delete");<br />      return map;<br />  }<br />  public ActionForward add(ActionMapping mapping,<br />          ActionForm form,          HttpServletRequest request,<br />          HttpServletResponse response) throws IOException, ServletException {<br />      // do add<br />      return mapping.findForward("success");<br />  }<br />  public ActionForward delete(ActionMapping mapping,<br />          ActionForm form,          HttpServletRequest request,<br />          HttpServletResponse response) throws IOException, ServletException {<br />      // do delete<br />      return mapping.findForward("success");<br />  }  <p><strong>Notes</strong> - If duplicate values exist for the keys returned by  getKeys, <br />only the first one found will be returned. If no corresponding key  is found <br />then an exception will be thrown. You can override the  method <code>unspecified</code> to<br /> provide a custom handler. If the submit  was cancelled (a <code>html:cancel</code> button<br /> was pressed), the custom  handler <code>cancelled</code> will be used instead.</p><p></p><p></p><hr /><p><!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><a target="_blank" rel="nofollow" name="field_summary"><!-- --></a></p><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableHeadingColor" bgcolor="#ccccff"><td colspan="2"><font size="+2"><b>Field Summary</b></font></td></tr><tr class="TableRowColor" bgcolor="white"><td valign="top" align="right" width="1%"><font size="-1"><code>protected  java.util.Map</code></font></td><td><code><b><a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#keyMethodMap" target="_blank" rel="nofollow"><font color="#00768a">keyMethodMap</font></a></b></code><br />          Resource key to method name lookup.</td></tr><tr class="TableRowColor" bgcolor="white"><td valign="top" align="right" width="1%"><font size="-1"><code>protected  java.util.Map</code></font></td><td><code><b><a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#localeMap" target="_blank" rel="nofollow"><font color="#00768a">localeMap</font></a></b></code><br />          Reverse lookup map from resource value to resource key.</td></tr></tbody></table> <a target="_blank" rel="nofollow" name="fields_inherited_from_class_org.apache.struts.actions.DispatchAction"><!-- --></a><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableSubHeadingColor" bgcolor="#eeeeff"><td><b>Fields inherited from class org.apache.struts.actions.<a title="class in org.apache.struts.actions" href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html" target="_blank" rel="nofollow"><font color="#00768a">DispatchAction</font></a></b></td></tr><tr class="TableRowColor" bgcolor="white"><td><code><a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#clazz" target="_blank" rel="nofollow"><font color="#00768a">clazz</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#log" target="_blank" rel="nofollow"><font color="#00768a">log</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#messages" target="_blank" rel="nofollow"><font color="#00768a">messages</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#methods" target="_blank" rel="nofollow"><font color="#00768a">methods</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#types" target="_blank" rel="nofollow"><font color="#00768a">types</font></a></code></td></tr></tbody></table> <a target="_blank" rel="nofollow" name="fields_inherited_from_class_org.apache.struts.action.Action"><!-- --></a><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableSubHeadingColor" bgcolor="#eeeeff"><td><b>Fields inherited from class org.apache.struts.action.<a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/Action.html" target="_blank" rel="nofollow"><font color="#00768a">Action</font></a></b></td></tr><tr class="TableRowColor" bgcolor="white"><td><code><a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#defaultLocale" target="_blank" rel="nofollow"><font color="#00768a">defaultLocale</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#servlet" target="_blank" rel="nofollow"><font color="#00768a">servlet</font></a></code></td></tr></tbody></table> <!-- ======== CONSTRUCTOR SUMMARY ======== --><a target="_blank" rel="nofollow" name="constructor_summary"><!-- --></a><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableHeadingColor" bgcolor="#ccccff"><td colspan="2"><font size="+2"><b>Constructor Summary</b></font></td></tr><tr class="TableRowColor" bgcolor="white"><td><code><b><a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#LookupDispatchAction()" target="_blank" rel="nofollow"><font color="#00768a">LookupDispatchAction</font></a></b>()</code><br />           </td></tr></tbody></table> <!-- ========== METHOD SUMMARY =========== --><a target="_blank" rel="nofollow" name="method_summary"><!-- --></a><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableHeadingColor" bgcolor="#ccccff"><td colspan="2"><font size="+2"><b>Method Summary</b></font></td></tr><tr class="TableRowColor" bgcolor="white"><td valign="top" align="right" width="1%"><font size="-1"><code> <a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionForward.html" target="_blank" rel="nofollow"><font color="#00768a">ActionForward</font></a></code></font></td><td><code><b><a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)" target="_blank" rel="nofollow"><font color="#00768a">execute</font></a></b>(<a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionMapping.html" target="_blank" rel="nofollow"><font color="#00768a">ActionMapping</font></a> mapping, <a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionForm.html" target="_blank" rel="nofollow"><font color="#00768a">ActionForm</font></a> form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)</code><br />          Process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it).</td></tr><tr class="TableRowColor" bgcolor="white"><td valign="top" align="right" width="1%"><font size="-1"><code>protected abstract  java.util.Map</code></font></td><td><code><b><a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#getKeyMethodMap()" target="_blank" rel="nofollow"><font color="#00768a">getKeyMethodMap</font></a></b>()</code><br />          Provides the mapping from resource key to method name.</td></tr><tr class="TableRowColor" bgcolor="white"><td valign="top" align="right" width="1%"><font size="-1"><code>protected  java.lang.String</code></font></td><td><code><b><a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#getLookupMapName(javax.servlet.http.HttpServletRequest, java.lang.String, org.apache.struts.action.ActionMapping)" target="_blank" rel="nofollow"><font color="#00768a">getLookupMapName</font></a></b>(javax.servlet.http.HttpServletRequest request, java.lang.String keyName, <a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionMapping.html" target="_blank" rel="nofollow"><font color="#00768a">ActionMapping</font></a> mapping)</code><br />          Lookup the method name corresponding to the client request's locale.</td></tr><tr class="TableRowColor" bgcolor="white"><td valign="top" align="right" width="1%"><font size="-1"><code>protected  java.lang.String</code></font></td><td><code><b><a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#getMethodName(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)" target="_blank" rel="nofollow"><font color="#00768a">getMethodName</font></a></b>(<a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionMapping.html" target="_blank" rel="nofollow"><font color="#00768a">ActionMapping</font></a> mapping, <a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionForm.html" target="_blank" rel="nofollow"><font color="#00768a">ActionForm</font></a> form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String parameter)</code><br />          Returns the method name, given a parameter's value.</td></tr><tr class="TableRowColor" bgcolor="white"><td valign="top" align="right" width="1%"><font size="-1"><code>private  java.util.Map</code></font></td><td><code><b><a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#initLookupMap(javax.servlet.http.HttpServletRequest, java.util.Locale)" target="_blank" rel="nofollow"><font color="#00768a">initLookupMap</font></a></b>(javax.servlet.http.HttpServletRequest request, java.util.Locale userLocale)</code><br />          This is the first time this Locale is used so build the reverse lookup Map.</td></tr></tbody></table> <a target="_blank" rel="nofollow" name="methods_inherited_from_class_org.apache.struts.actions.DispatchAction"><!-- --></a><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableSubHeadingColor" bgcolor="#eeeeff"><td><b>Methods inherited from class org.apache.struts.actions.<a title="class in org.apache.struts.actions" href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html" target="_blank" rel="nofollow"><font color="#00768a">DispatchAction</font></a></b></td></tr><tr class="TableRowColor" bgcolor="white"><td><code><a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#cancelled(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)" target="_blank" rel="nofollow"><font color="#00768a">cancelled</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#dispatchMethod(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)" target="_blank" rel="nofollow"><font color="#00768a">dispatchMethod</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#getMethod(java.lang.String)" target="_blank" rel="nofollow"><font color="#00768a">getMethod</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#unspecified(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)" target="_blank" rel="nofollow"><font color="#00768a">unspecified</font></a></code></td></tr></tbody></table> <a target="_blank" rel="nofollow" name="methods_inherited_from_class_org.apache.struts.action.Action"><!-- --></a><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableSubHeadingColor" bgcolor="#eeeeff"><td><b>Methods inherited from class org.apache.struts.action.<a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/Action.html" target="_blank" rel="nofollow"><font color="#00768a">Action</font></a></b></td></tr><tr class="TableRowColor" bgcolor="white"><td><code><a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#addErrors(javax.servlet.http.HttpServletRequest, org.apache.struts.action.ActionMessages)" target="_blank" rel="nofollow"><font color="#00768a">addErrors</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#addMessages(javax.servlet.http.HttpServletRequest, org.apache.struts.action.ActionMessages)" target="_blank" rel="nofollow"><font color="#00768a">addMessages</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.ServletRequest, javax.servlet.ServletResponse)" target="_blank" rel="nofollow"><font color="#00768a">execute</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#generateToken(javax.servlet.http.HttpServletRequest)" target="_blank" rel="nofollow"><font color="#00768a">generateToken</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#getDataSource(javax.servlet.http.HttpServletRequest)" target="_blank" rel="nofollow"><font color="#00768a">getDataSource</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#getDataSource(javax.servlet.http.HttpServletRequest, java.lang.String)" target="_blank" rel="nofollow"><font color="#00768a">getDataSource</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#getErrors(javax.servlet.http.HttpServletRequest)" target="_blank" rel="nofollow"><font color="#00768a">getErrors</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#getLocale(javax.servlet.http.HttpServletRequest)" target="_blank" rel="nofollow"><font color="#00768a">getLocale</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#getMessages(javax.servlet.http.HttpServletRequest)" target="_blank" rel="nofollow"><font color="#00768a">getMessages</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#getResources(javax.servlet.http.HttpServletRequest)" target="_blank" rel="nofollow"><font color="#00768a">getResources</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#getResources(javax.servlet.http.HttpServletRequest, java.lang.String)" target="_blank" rel="nofollow"><font color="#00768a">getResources</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#getServlet()" target="_blank" rel="nofollow"><font color="#00768a">getServlet</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#isCancelled(javax.servlet.http.HttpServletRequest)" target="_blank" rel="nofollow"><font color="#00768a">isCancelled</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#isTokenValid(javax.servlet.http.HttpServletRequest)" target="_blank" rel="nofollow"><font color="#00768a">isTokenValid</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#isTokenValid(javax.servlet.http.HttpServletRequest, boolean)" target="_blank" rel="nofollow"><font color="#00768a">isTokenValid</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#resetToken(javax.servlet.http.HttpServletRequest)" target="_blank" rel="nofollow"><font color="#00768a">resetToken</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#saveErrors(javax.servlet.http.HttpServletRequest, org.apache.struts.action.ActionErrors)" target="_blank" rel="nofollow"><font color="#00768a">saveErrors</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#saveErrors(javax.servlet.http.HttpServletRequest, org.apache.struts.action.ActionMessages)" target="_blank" rel="nofollow"><font color="#00768a">saveErrors</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#saveMessages(javax.servlet.http.HttpServletRequest, org.apache.struts.action.ActionMessages)" target="_blank" rel="nofollow"><font color="#00768a">saveMessages</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#saveMessages(javax.servlet.http.HttpSession, org.apache.struts.action.ActionMessages)" target="_blank" rel="nofollow"><font color="#00768a">saveMessages</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#saveToken(javax.servlet.http.HttpServletRequest)" target="_blank" rel="nofollow"><font color="#00768a">saveToken</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#setLocale(javax.servlet.http.HttpServletRequest, java.util.Locale)" target="_blank" rel="nofollow"><font color="#00768a">setLocale</font></a>, <a href="http://struts.apache.org/api/org/apache/struts/action/Action.html#setServlet(org.apache.struts.action.ActionServlet)" target="_blank" rel="nofollow"><font color="#00768a">setServlet</font></a></code></td></tr></tbody></table> <a target="_blank" rel="nofollow" name="methods_inherited_from_class_java.lang.Object"><!-- --></a><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableSubHeadingColor" bgcolor="#eeeeff"><td><b>Methods inherited from class java.lang.Object</b></td></tr><tr class="TableRowColor" bgcolor="white"><td><code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></td></tr></tbody></table> <p><!-- ============ FIELD DETAIL =========== --><a target="_blank" rel="nofollow" name="field_detail"><!-- --></a></p><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableHeadingColor" bgcolor="#ccccff"><td><font size="+2"><b>Field Detail</b></font></td></tr></tbody></table><a target="_blank" rel="nofollow" name="localeMap"><!-- --></a><h3>localeMap</h3><pre>protected java.util.Map <b>localeMap</b></pre><dl><dd>Reverse lookup map from resource value to resource key.<p></p><dl></dl></dd></dl><hr /><a target="_blank" rel="nofollow" name="keyMethodMap"><!-- --></a><h3>keyMethodMap</h3><pre>protected java.util.Map <b>keyMethodMap</b></pre><dl><dd>Resource key to method name lookup.<p></p><dl></dl></dd></dl><!-- ========= CONSTRUCTOR DETAIL ======== --><a target="_blank" rel="nofollow" name="constructor_detail"><!-- --></a><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableHeadingColor" bgcolor="#ccccff"><td><font size="+2"><b>Constructor Detail</b></font></td></tr></tbody></table><a target="_blank" rel="nofollow" name="LookupDispatchAction()"><!-- --></a><h3>LookupDispatchAction</h3><pre>public <b>LookupDispatchAction</b>()</pre><dl></dl><!-- ============ METHOD DETAIL ========== --><a target="_blank" rel="nofollow" name="method_detail"><!-- --></a><table cellspacing="0" cellpadding="3" width="100%" summary="" border="1"><tbody><tr class="TableHeadingColor" bgcolor="#ccccff"><td><font size="+2"><b>Method Detail</b></font></td></tr></tbody></table><a target="_blank" rel="nofollow" name="execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)"><!-- --></a><h3>execute</h3><pre>public <a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionForward.html" target="_blank" rel="nofollow"><font color="#00768a">ActionForward</font></a><b>execute</b>(<a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionMapping.html" target="_blank" rel="nofollow"><font color="#00768a">ActionMapping</font></a> mapping,<br /><a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionForm.html" target="_blank" rel="nofollow"><font color="#00768a">ActionForm</font></a> form, <br />                            javax.servlet.http.HttpServletRequest request,<br />                             javax.servlet.http.HttpServletResponse response)<br />                      throws java.lang.Exception<br /></pre><dl><dd>Process the specified HTTP request, and create the corresponding HTTP  <br />response (or forward to another web component that will create it).  <br />Return an <code>ActionForward</code> instance describing where and how  control should <br />be forwarded, or <code>null</code> if the response has  already been completed.<br /><p></p></dd><dd><dl><dt><b>Overrides:</b></dt><dd><code><a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)" target="_blank" rel="nofollow"><font color="#00768a">execute</font></a></code> in class <code><a title="class in org.apache.struts.actions" href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html" target="_blank" rel="nofollow"><font color="#00768a">DispatchAction</font></a></code></dd></dl></dd><dd><dl><dt><b>Parameters:</b></dt><dd><code>mapping</code> - The ActionMapping used to select this instance</dd><dd><code>request</code> - The HTTP request we are processing</dd><dd><code>response</code> - The HTTP response we are creating</dd><dd><code>form</code> - The optional ActionForm bean for this request (if any)</dd><dt><b>Returns:</b></dt><dd>Describes where and how control should be forwarded.</dd><dt><b>Throws:</b></dt><dd><code>java.lang.Exception</code> - if an error occurs</dd></dl></dd></dl><hr /><a target="_blank" rel="nofollow" name="initLookupMap(javax.servlet.http.HttpServletRequest, java.util.Locale)"><!-- --></a><h3>initLookupMap</h3><pre>private java.util.Map <b>initLookupMap</b>(<br />                                 javax.servlet.http.HttpServletRequest request,<br />                                    java.util.Locale userLocale)<br /></pre><dl><dd>This is the first time this Locale is used so build the reverse lookup Map.<br /> Search for message keys in all configured MessageResources for the current <br />module.<p></p></dd><dd><dl></dl></dd></dl><hr /><a target="_blank" rel="nofollow" name="getKeyMethodMap()"><!-- --></a><h3>getKeyMethodMap</h3><pre>protected abstract java.util.Map <b>getKeyMethodMap</b>()</pre><dl><dd>Provides the mapping from resource key to method name.<br /><p></p></dd><dd><dl><dt><b>Returns:</b></dt><dd>Resource key / method name map.</dd></dl></dd></dl><hr /><a target="_blank" rel="nofollow" name="getLookupMapName(javax.servlet.http.HttpServletRequest, java.lang.String, org.apache.struts.action.ActionMapping)"><!-- --></a><h3>getLookupMapName</h3><pre>protected java.lang.String <b>getLookupMapName</b>(<br />                        javax.servlet.http.HttpServletRequest request,<br />                                            java.lang.String keyName,<br /><a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionMapping.html" target="_blank" rel="nofollow"><font color="#00768a">ActionMapping</font></a> mapping)<br />                                     throws javax.servlet.ServletException<br /></pre><dl><dd>Lookup the method name corresponding to the client request's locale.<p></p></dd><dd><dl><dt><b>Parameters:</b></dt><dd><code>request</code> - The HTTP request we are processing</dd><dd><code>keyName</code> - The parameter name to use as the properties key</dd><dd><code>mapping</code> - The ActionMapping used to select this instance</dd><dt><b>Returns:</b></dt><dd>The method's localized name.</dd><dt><b>Throws:</b></dt><dd><code>javax.servlet.ServletException</code> - if keyName cannot be resolved</dd><dt><b>Since:</b></dt><dd>Struts 1.2.0</dd></dl></dd></dl><hr /><a target="_blank" rel="nofollow" name="getMethodName(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)"><!-- --></a><h3>getMethodName</h3><pre>protected java.lang.String <b>getMethodName</b>(<a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionMapping.html" target="_blank" rel="nofollow"><font color="#00768a">ActionMapping</font></a> mapping,<br /><a title="class in org.apache.struts.action" href="http://struts.apache.org/api/org/apache/struts/action/ActionForm.html" target="_blank" rel="nofollow"><font color="#00768a">ActionForm</font></a> form,<br />                                    javax.servlet.http.HttpServletRequest request,<br />                                    javax.servlet.http.HttpServletResponse response,<br />                                     java.lang.String parameter)<br />                                  throws java.lang.Exception<br /></pre><dl><dd>Returns the method name, given a parameter's value.<p></p></dd><dd><dl><dt><b>Overrides:</b></dt><dd><code><a href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html#getMethodName(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)" target="_blank" rel="nofollow"><font color="#00768a">getMethodName</font></a></code> in class <code><a title="class in org.apache.struts.actions" href="http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html" target="_blank" rel="nofollow"><font color="#00768a">DispatchAction</font></a></code></dd></dl></dd><dd><dl><dt><b>Parameters:</b></dt><dd><code>mapping</code> - The ActionMapping used to select this instance</dd><dd><code>form</code> - The optional ActionForm bean for this request (if any)</dd><dd><code>request</code> - The HTTP request we are processing</dd><dd><code>response</code> - The HTTP response we are creating</dd><dd><code>parameter</code> - The <code>ActionMapping</code> parameter's name</dd><dt><b>Returns:</b></dt><dd>The method's name.</dd><dt><b>Throws:</b></dt><dd><code>java.lang.Exception</code></dd><dt><b>Since:</b></dt><dd>Struts 1.2.0</dd></dl></dd></dl><!-- ========= END OF CLASS DATA ========= --><hr /><!-- ======= START OF BOTTOM NAVBAR ====== --><a target="_blank" rel="nofollow" name="navbar_bottom"><!-- --></a><a title="Skip navigation links" href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#skip-navbar_bottom" target="_blank" rel="nofollow"></a><table cellspacing="0" cellpadding="1" width="100%" summary="" border="0"><tbody><tr><td class="NavBarCell1" bgcolor="#eeeeff" colspan="3"><a target="_blank" rel="nofollow" name="navbar_bottom_firstrow"><!-- --></a><table cellspacing="3" cellpadding="0" summary="" border="0"><tbody><tr valign="top" align="middle"><td class="NavBarCell1" bgcolor="#eeeeff"><a href="http://struts.apache.org/api/overview-summary.html" target="_blank" rel="nofollow"><font class="NavBarFont1" color="#00768a"><b>Overview</b></font></a> </td><td class="NavBarCell1" bgcolor="#eeeeff"><a href="http://struts.apache.org/api/org/apache/struts/actions/package-summary.html" target="_blank" rel="nofollow"><font class="NavBarFont1" color="#00768a"><b>Package</b></font></a> </td><td class="NavBarCell1Rev" bgcolor="#ffffff"> <font class="NavBarFont1Rev"><b>Class</b></font> </td><td class="NavBarCell1" bgcolor="#eeeeff"><a href="http://struts.apache.org/api/org/apache/struts/actions/class-use/LookupDispatchAction.html" target="_blank" rel="nofollow"><font class="NavBarFont1" color="#00768a"><b>Use</b></font></a> </td><td class="NavBarCell1" bgcolor="#eeeeff"><a href="http://struts.apache.org/api/org/apache/struts/actions/package-tree.html" target="_blank" rel="nofollow"><font class="NavBarFont1" color="#00768a"><b>Tree</b></font></a> </td><td class="NavBarCell1" bgcolor="#eeeeff"><a href="http://struts.apache.org/api/deprecated-list.html" target="_blank" rel="nofollow"><font class="NavBarFont1" color="#00768a"><b>Deprecated</b></font></a> </td><td class="NavBarCell1" bgcolor="#eeeeff"><a href="http://struts.apache.org/api/index-all.html" target="_blank" rel="nofollow"><font class="NavBarFont1" color="#00768a"><b>Index</b></font></a> </td><td class="NavBarCell1" bgcolor="#eeeeff"><a href="http://struts.apache.org/api/help-doc.html" target="_blank" rel="nofollow"><font class="NavBarFont1" color="#00768a"><b>Help</b></font></a> </td></tr></tbody></table></td><td valign="top" align="right" rowspan="3"><em></em></td></tr><tr><td class="NavBarCell2" bgcolor="white"><font size="-2"> <a title="class in org.apache.struts.actions" href="http://struts.apache.org/api/org/apache/struts/actions/LocaleAction.html" target="_blank" rel="nofollow"><b><font color="#00768a">PREV CLASS</font></b></a>   <a title="class in org.apache.struts.actions" href="http://struts.apache.org/api/org/apache/struts/actions/MappingDispatchAction.html" target="_blank" rel="nofollow"><b><font color="#00768a">NEXT CLASS</font></b></a></font></td><td class="NavBarCell2" bgcolor="white"><font size="-2"><a href="http://struts.apache.org/api/index.html" target="_blank" rel="nofollow"><b><font color="#00768a">FRAMES</font></b></a>    <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html" target="_blank" rel="nofollow"><b><font color="#00768a">NO FRAMES</font></b></a>     <!--  if(window==top) {    document.writeln('<a target="_blank" rel="nofollow" HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');  }  //--><a href="http://struts.apache.org/api/allclasses-noframe.html" target="_blank" rel="nofollow"><b><font color="#00768a">All Classes</font></b></a><a href="http://www.nimoblog.cn/allclasses-noframe.html" target="_blank" rel="nofollow"><b><font color="#00768a">All Classes</font></b></a></font></td></tr><tr><td class="NavBarCell3" valign="top"><font size="-2">SUMMARY: NESTED | <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#field_summary" target="_blank" rel="nofollow"><font color="#00768a">FIELD</font></a> | <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#constructor_summary" target="_blank" rel="nofollow"><font color="#00768a">CONSTR</font></a> | <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#method_summary" target="_blank" rel="nofollow"><font color="#00768a">METHOD</font></a></font></td><td class="NavBarCell3" valign="top"><font size="-2">DETAIL: <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#field_detail" target="_blank" rel="nofollow"><font color="#00768a">FIELD</font></a> | <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#constructor_detail" target="_blank" rel="nofollow"><font color="#00768a">CONSTR</font></a> | <a href="http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html#method_detail" target="_blank" rel="nofollow"><font color="#00768a">METHOD</font></a></font></td></tr></tbody></table><a target="_blank" rel="nofollow" name="skip-navbar_bottom"></a><!-- ======== END OF BOTTOM NAVBAR ======= --><font color="#00768a"><hr /></font>Copyright © 2000-2004 - The Apache Software Foundation</pre><br /><br /><!-- Body End --><script language="javascript" src="bodyend.js"></script><script src="http://www.google-analytics.com/urchin.js" defer="" type="text/javascript"></script><script defer="" type="text/javascript"><![CDATA[uacct = "UA-469010-2";urchinTracker();]]&gt;</script><img src ="http://www.blogjava.net/web/aggbug/59275.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-20 18:18 <a href="http://www.blogjava.net/web/archive/2006/07/20/Class_LookupDispatchAction_HTMLHelp.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>LookupDispatchAction使用示例（中文）（转）</title><link>http://www.blogjava.net/web/archive/2006/07/20/LookupDispatchAction_zh.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 20 Jul 2006 10:04:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/20/LookupDispatchAction_zh.html</guid><wfw:comment>http://www.blogjava.net/web/comments/59264.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/20/LookupDispatchAction_zh.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/59264.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/59264.html</trackback:ping><description><![CDATA[org.apache.struts.actions.LookupDispatchAction类别是 DispatchAction 类别的子类，与DispatchAction类似的是，它透过请求上的参数来决定该执行哪一个方法，不过LookupDispatchAction多了查 询讯息资源档案的功能，LookupDispatchAction的用处之一，就是当一个表单中包括两个以上的按钮时，可以透过查询讯息资源档来确定相对 应的动作。<br /><br />直接以实例来说明，在继承LookupDispatchAction之後，您要重新定义getKeyMethodMap()方法，并定义好自己的相关处理方法，例如：<br /><ul><li>EditAction.java </li></ul><pre>package onlyfun.caterpillar;<br /><br />import javax.servlet.http.*; <br />import org.apache.struts.action.*; <br />import org.apache.struts.actions.*;<br /><br />public class EditAction extends LookupDispatchAction { <br />    protected Map getKeyMethodMap() { <br />        Map map = new HashMap();<br />        map.put("button.save", "save");<br />        map.put("button.preview", "preview"); <br />        map.put("button.reset", "reset"); <br />        return map; <br />    }<br /><br />    public ActionForward save(ActionMapping mapping, <br />                              ActionForm form, <br />                              HttpServletRequest request, <br />                              HttpServletResponse response) <br />                                 throws Exception { <br />        // ...... <br />    }<br /><br />    public ActionForward preview(ActionMapping mapping, <br />                              ActionForm form, <br />                              HttpServletRequest request, <br />                              HttpServletResponse response) <br />                                 throws Exception { <br />        // ...... <br />    }<br /><br />    public ActionForward reset(ActionMapping mapping, <br />                              ActionForm form, <br />                              HttpServletRequest request, <br />                              HttpServletResponse response) <br />                                 throws Exception { <br />        // ...... <br />    }                                                              <br />}</pre><span class="postbody"></span><br />假设讯息资源档中包括以下的讯息：<br /><ul><li>messages.properties </li></ul><pre>button.save=Save<br />button.preview=Preview<br />button.reset=Reset</pre><br />为了要使用LookupDispatchAction，在struts-config.xml中定义请求参数中该有的名称：<br /><ul><li>struts-config.xml </li></ul><pre>...<br />   &lt;action path="/edit"<br />           type="onlyfun.caterpillar.EditAction" <br />           parameter="method" <br />           name="editForm"/&gt;<br />... </pre><br />现在假设您的表单页面包括以下的内容：<br /><div style="MARGIN-LEFT: 40px"><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">...</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"> &lt;form name="editForm" method="post" </span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">       action="/strutsapp/edit.do"&gt; </span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">    .....</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">    &lt;input type="submit" name="method" value="Save"/&gt; </span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">    &lt;input type="submit" name="method" value="Preview"/&gt;</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">    &lt;input type="submit" name="method" value="Reset"/&gt; </span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"> &lt;/form&gt;</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">...</span><br /></div><br />当您按下任一个按钮时，请求参数中会包括method=Save或是method=Preview或是method= Reset，假设是method=Save好了，LookupDispatchAction会根据它作为value，在讯息资讯档找到对应的key，然後 根据key与getKeyMethodMap()得知要执行的方法为save()方法。<br /><br />那么关於国际化讯息管理的部份呢？例如想要在表单按钮上使用中文？<br /><div style="MARGIN-LEFT: 40px"><span style="FONT-FAMILY: Courier New,Courier,monospace"> </span><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">...</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"> &lt;form name="editForm" method="post" </span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">       action="/strutsapp/edit.do"&gt; </span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">    .....</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">    &lt;input type="submit" name="method" value="存档"/&gt; </span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">    &lt;input type="submit" name="method" value="预览"/&gt;</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">    &lt;input type="submit" name="method" value="重设"/&gt; </span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"> &lt;/form&gt;</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">...</span><br /></div><br />一样的，您的讯息档案中必须包括下面的内容：<br /><ul><li>messages.properties </li></ul><pre>button.save=存档<br />button.preview=预览<br />button.reset=重设</pre><br />然後，您要使用native2ascii将讯息档案转换为Unicode编码，例如：<br /><table style="WIDTH: 100%; TEXT-ALIGN: left" cellspacing="2" cellpadding="2" border="0"><tbody><tr><td style="BACKGROUND-COLOR: rgb(0,0,0)"><small><span style="COLOR: rgb(255,255,255)">native2ascii messages_zh_TW.txt messages_zh_TW.properties</span></small><span style="COLOR: rgb(255,255,255)"><br /></span></td></tr></tbody></table><br />接下来的问题是，浏览器发送过来的中文参数，为了要能正确的解析，要使用request的 setCharacterEncoding("Big5")，这样才能得到正确的中文参数，但是在什么地方作这个动作？您可以在Servlet Filter中作这件事，另一个可能的地方则是 ActionForm 的reset()方法中，例如：<br /><div style="MARGIN-LEFT: 40px"><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">package onlyfun.caterpillar;</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">public class UserForm extends ActionForm {</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">     ......</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">    public void reset(ActionMapping mapping, </span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">                     HttpServletRequest request) {</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">        try {</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">            request.setCharacterEncoding("Big5");</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">            .......</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">        } </span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">        catch(Exception e) {</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">            ....</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">        }</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">   }</span><br style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace" /><span style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">}</span><br /></div> <br /><br />这样您的按钮就可以使用中文讯息了。<br /><br />如果您愿意的话，可以搭配使用 <a href="http://www.cntesting.com/pic/study/Struts/BeanMessage.htm">&lt;bean:message&gt;</a> 来使用上述的功能，直接由标签来管理讯息档案中的讯息。<br /><br /><img src ="http://www.blogjava.net/web/aggbug/59264.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-20 18:04 <a href="http://www.blogjava.net/web/archive/2006/07/20/LookupDispatchAction_zh.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>LookupDispatchAction使用示例</title><link>http://www.blogjava.net/web/archive/2006/07/20/LookupDispatchAction.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 20 Jul 2006 10:01:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/20/LookupDispatchAction.html</guid><wfw:comment>http://www.blogjava.net/web/comments/59263.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/20/LookupDispatchAction.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/59263.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/59263.html</trackback:ping><description><![CDATA[<strong>LookupDispatchAction <br /></strong>
		<table width="100%" border="0">
				<tbody>
						<tr>
								<td class="LIST">
										<br />
										<dl>
												<dt>public abstract class <b>LookupDispatchAction</b></dt>
												<dt>extends <a title="class in org.apache.struts.actions" href="http://struts.apache.org/struts-doc-1.2.x/api/org/apache/struts/actions/DispatchAction.html"><font color="#777777">DispatchAction</font></a></dt>
										</dl>
										<p>
												<font color="#777777">
												</font>
										</p>
										<p>An abstract <strong>Action</strong> that dispatches to the subclass mapped <code>execute</code> method. This is useful in cases where an HTML form has multiple submit buttons with the same name. The button name is specified by the <code>parameter</code> property of the corresponding ActionMapping. To configure the use of this action in your <code>struts-config.xml</code> file, create an entry like this:</p>
										<pre>   &lt;action path="/test"
           type="org.example.MyAction"
           name="MyForm"
          scope="request"
          input="/test.jsp"
      parameter="method"/&gt;
 </pre>
										<p>which will use the value of the request parameter named "method" to locate the corresponding key in ApplicationResources. For example, you might have the following ApplicationResources.properties:</p>
										<pre>    button.add=Add Record
    button.delete=Delete Record
  </pre>
										<p>And your JSP would have the following format for submit buttons:</p>
										<pre>   &lt;html:form action="/test"&gt;
    &lt;html:submit property="method"&gt;
      &lt;bean:message key="button.add"/&gt;
    &lt;/html:submit&gt;
    &lt;html:submit property="method"&gt;
      &lt;bean:message key="button.delete"/&gt;
    &lt;/html:submit&gt;
  &lt;/html:form&gt;
  </pre>
										<p>Your subclass must implement both getKeyMethodMap and the methods defined in the map. An example of such implementations are:</p>
										<pre>  protected Map getKeyMethodMap() {
      Map map = new HashMap();
      map.put("button.add", "add");
      map.put("button.delete", "delete");
      return map;
  }

  public ActionForward add(ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response)
          throws IOException, ServletException {
      // do add
      return mapping.findForward("success");
  }

  public ActionForward delete(ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response)
          throws IOException, ServletException {
      // do delete
      return mapping.findForward("success");
  }
  <p><strong>Notes</strong> - If duplicate values exist for the keys returned by
  getKeys, only the first one found will be returned. If no corresponding key
  is found then an exception will be thrown. You can override the
  method <code>unspecified</code> to provide a custom handler. If the submit
  was cancelled (a <code>html:cancel</code> button was pressed), the custom
  handler <code>cancelled</code> will be used instead.
</p><p> </p></pre>
								</td>
						</tr>
				</tbody>
		</table><img src ="http://www.blogjava.net/web/aggbug/59263.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-20 18:01 <a href="http://www.blogjava.net/web/archive/2006/07/20/LookupDispatchAction.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts七点经验－2（转）</title><link>http://www.blogjava.net/web/archive/2006/07/20/experience7_2_struts.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 20 Jul 2006 09:25:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/20/experience7_2_struts.html</guid><wfw:comment>http://www.blogjava.net/web/comments/59247.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/20/experience7_2_struts.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/59247.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/59247.html</trackback:ping><description><![CDATA[<strong>
				<font color="#ac0000">3. 使用应用模块（Application Modules）<br /><br /></font>
		</strong>　　Struts 1.1的一个新特性是应用模块的概念。应用模块允许将单个Struts应用划分成几个模块，每个模块有自己的Struts配置文件，JSP页面，Action等等。这个新特性是为了解决大中型的开发队伍抱怨最多的一个问题，即为了更好的支持并行开发允许多个配置文件而不是单个配置文件。<br /><br />　　注：在早期的beta版本中，该特性被称为子应用（sub-applications），最近的改名目的是为了更多地反映它们在逻辑上的分工。<br /><br />　　显然，当很多开发人员一起参加一个项目时，单个的Struts配置文件很容易引起资源冲突。应用模块允许Struts按照功能要求进行划分，许多情况已经证明这样更贴近实际。例如，假设我们要开发一个典型的商店应用程序。可以将组成部分划分成模块比如catalog（商品目录）, customer（顾客）, customer service（顾客服务）, order（订单）等。每个模块可以分布到不同的目录下，这样各部分的资源很容易定位，有助于开发和部署。图1 显示了该应用的目录结构。<br /><br /><table width="600" align="center"><tbody><tr align="middle"><td><img height="242" src="http://www.yesky.com/SoftChannel/72342371961929728/20021203/jt-2002-1203-image004.jpg" width="156" /><br />图 1. 一个典型的商店应用程序的目录结构 </td></tr></tbody></table><br />　　注：如果你无需将项目划分成多个模块，Struts框架支持一个缺省的应用模块。这就使得应用程序也可以在1.0版本下创建，具有可移植性，因为应用程序会自动作为缺省的应用模块。<br /><br />　　为了使用多应用模块功能，必须执行以下几个准备步骤：<br /><br />　　· 为每个应用模块创建独立的Struts配置文件。<br /><br />　　· 配置Web 部署描述符 Web.xml文件。<br /><br />　　· 使用org.apache.struts.actions.SwitchAction 来实现程序在模块之间的跳转. <br /><br />　　<b>创建独立的Struts配置文件</b><br /><br />　　每个Struts应用模块必须拥有自己的配置文件。允许创建自己的独立于其他模块的Action，ActionForm，异常处理甚至更多。<br /><br />　　继续以上面的商店应用程序为例，我们可以创建以下的配置文件：一个文件名为struts-config-catalog.xml，包含catalog（商品目录）、items(商品清单)、和其它与库存相关的功能的配置信息；另一个文件名为struts- config-order.xml, 包含对order（订单）和order tracking（订单跟踪）的设置。第三个配置文件是struts-config.xml,其中含有属于缺省的应用模块中的一般性的功能。<br /><br />　　<b>配置Web部署描述符 </b><br /><br />　　在Struts的早期版本中，我们在Web.xml中指定Struts配置文件的路径。好在这点没变，有助于向后兼容。但对于多个应用模块，我们需要在Web部署描述符中增加新的配置文件的设定。<br /><br />　　对于缺省的应用（包括Struts的早期版本），Struts framework 在Web.xml文件中查找带有config的元素<init-param>，用于载入Action mapping 和其它的应用程序设定。作为例子，以下的XML片断展现一个典型的<init-param>元素：<br /><br /><table width="600" align="center"><tbody><tr><td><img height="115" src="http://www.yesky.com/SoftChannel/72342371961929728/20021203/jt-2002-1203-image005.gif" width="487" /></td></tr></tbody></table><br />　　注：如果在现有的<init-param>元素中找不到"config"关键字，Struts framework将缺省地使用/WEB/struts-config.xml<br /><br />　　为了支持多个应用模块(Struts 1.1的新特性)，必须增加附加的<init-param>元素。与缺省的<init-param>元素不同的是，附加的<init-param>元素与每个应用模块对应，必须以config/xxx的形式命名，其中字符串xxx代表该模块唯一的名字。例如，在商店应用程序的例子中，<init-param>元素可定义如下（注意粗体字部分）：<br /><br /><table width="600" align="center"><tbody><tr><td><img height="272" src="http://www.yesky.com/SoftChannel/72342371961929728/20021203/jt-2002-1203-image006.gif" width="487" /></td></tr></tbody></table><br /><br />　　第一个 <init-param>元素对应缺省的应用模块。第二和第三个元素分别代表非缺省应用模块catalog 和 order。<br /><br />　　当Struts载入应用程序时，它首先载入缺省应用模块的配置文件。然后查找带有字符串config/xxx 形式的附加的初始化参数。对每个附加的配置文件也进行解析并载入内存。这一步完成后，用户就可以很随意地用config/后面的字符串也就是名字来调用相应的应用模块。<br /><br />　　<b>多个应用模块之间调用Action类</b><br /><br />　　在为每个应用模块创建独立的配置文件之后，我们就有可能需要调用不同的模块中Action。为此必须使用Struts框架提供的SwitchAction类。Struts 会自动将应用模块的名字添加到URL,就如Struts 自动添加应用程序的名字加到URL一样。应用模块是对框架的一个新的扩充，有助于进行并行的团队开发。如果你的团队很小那就没必要用到这个特性，不必进行模块化。当然，就算是只有一个模块，系统还是一样的运作。<br /><br />　　<b><font color="#ac000">4. 把JSP放到WEB-INF后以保护JSP源代码</font></b><br /><br />　　为了更好地保护你的JSP避免未经授权的访问和窥视， 一个好办法是将页面文件存放在Web应用的WEB-INF目录下。<br /><br />　　通常JSP开发人员会把他们的页面文件存放在Web应用相应的子目录下。一个典型的商店应用程序的目录结构如图2所示。跟catalog （商品目录）相关的JSP被保存在catalog子目录下。跟customer相关的JSP，跟订单相关的JSP等都按照这种方法存放。<br /><br /><table width="600" align="center"><tbody><tr align="middle"><td><img height="242" src="http://www.yesky.com/SoftChannel/72342371961929728/20021203/jt-2002-1203-image007.jpg" width="156" /><br />图 2.基于不同的功能 JSP 被放置在不同的目录下 </td></tr></tbody></table><br />　　这种方法的问题是这些页面文件容易被偷看到源代码，或被直接调用。某些场合下这可能不是个大问题，可是在特定情形中却可能构成安全隐患。用户可以绕过Struts的controller直接调用JSP同样也是个问题。<br />为了减少风险，可以把这些页面文件移到WEB-INF 目录下。基于Servlet的声明，WEB-INF不作为Web应用的公共文档树的一部分。因此，WEB-INF 目录下的资源不是为客户直接服务的。我们仍然可以使用WEB-INF目录下的JSP页面来提供视图给客户，客户却不能直接请求访问JSP。<br /><br />　　采用前面的例子，图3显示将JSP页面移到WEB-INF 目录下后的目录结构<br /><br /><table width="600" align="center"><tbody><tr align="middle"><td><img height="237" src="http://www.yesky.com/SoftChannel/72342371961929728/20021203/jt-2002-1203-image008.jpg" width="149" /><br />图 3. JSP存放在 WEB-INF 目录下更为安全 </td></tr></tbody></table><br />　　如果把这些JSP页面文件移到WEB-INF 目录下，在调用页面的时候就必须把"WEB-INF"添加到URL中。例如，在一个Struts配置文件中为一个logoff action写一个Action mapping。其中JSP的路径必须以"WEB-INF"开头。如下所示：请注意粗体部分.<br /><br />　　这个方法在任何情况下都不失为Struts实践中的一个好方法。是唯一要注意的技巧是你必须把JSP和一个Struts action联系起来。即使该Action只是一个很基本的很简单JSP，也总是要调用一个Action，再由它调用JSP。<br /><br />　　最后要说明的是，并不是所有的容器都能支持这个特性。WebLogic早期的版本不能解释Servlet声明，因此无法提供支持，据报道在新版本中已经改进了。总之使用之前先检查一下你的Servlet容器。<br /><br /></init-param></init-param></init-param></init-param></init-param></init-param></init-param></init-param><img src ="http://www.blogjava.net/web/aggbug/59247.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-20 17:25 <a href="http://www.blogjava.net/web/archive/2006/07/20/experience7_2_struts.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts的七点经验－1(转)</title><link>http://www.blogjava.net/web/archive/2006/07/20/experience7_1_struts.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 20 Jul 2006 09:20:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/20/experience7_1_struts.html</guid><wfw:comment>http://www.blogjava.net/web/comments/59240.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/20/experience7_1_struts.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/59240.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/59240.html</trackback:ping><description><![CDATA[<strong>
				<font color="#ac0000">1. 只在必要的时候才考虑扩展Struts框架 <br /><br /></font>
		</strong>　　一个好的framework有很多优点，首先，它必须能够满足用户的可预见的需求。为此 Struts为Web 应用提供了一个通用的架构，这样开发人员可以把精力集中在如何解决实际业务问题上。其次，一个好的framework还必须能够在适当的地方提供扩展接口，以便应用程序能扩展该框架来更好的适应使用者的实际需要。<br /><br />　　如果Struts framework在任何场合，任何项目中都能很好的满足需求，那真是太棒了。但是实际上，没有一个框架声称能做到这一点。一定会有一些特定的应用需求是框架的开发者们无法预见到的。因此，最好的办法就是提供足够的扩展接口，使得开发工程师能够调整struts来更好的符合他们的特殊要求。<br /><br />　　在Struts framework中有很多地方可供扩展和定制。几乎所有的配置类都能被替换为某个用户定制的版本，这只要简单的修改一下Struts的配置文件就可以做到。<br /><br />　　其他组件如ActionServlet和 RequestProcessor 也能用自定义的版本代替. 甚至连Struts 1.1里才有的新特性也是按照扩展的原则来设计的。例如，在异常处理机制中就允许用户定制异常处理的句柄，以便更好的对应用系统发生的错误做出响应。<br /><br />　　作为框架的这种可调整特性在它更适合你的应用的同时也在很大的程度上影响了项目开发的效果。首先，由于您的应用是基于一个现有的成熟的、稳定的framework如Struts，测试过程中发现的错误数量将会大大减少，同时也能缩短开发时间和减少资源的投入。因为你不再需要投入开发力量用于编写基础框架的代码了。<br /><br />　　然而, 实现更多的功能是要花费更大的代价的。我们必须小心避免不必要的滥用扩展性能， Struts是由核心包加上很多工具包构成的，它们已经提供了很多已经实现的功能。因此不要盲目的扩展Struts框架，要先确定能不能采用其他方法使用现有的功能来实现。 在决定编写扩展代码前务必要确认Struts的确没有实现你要的功能。否则重复的功能会导致混乱将来还得花费额外的精力清除它。<br /><br />　　<b><font color="#ac000">2. 使用异常处理声明</font></b><br /><br />　　要定义应用程序的逻辑流程，成熟的经验是推荐在代码之外，用配置的方法来实现，而不是写死在程序代码中的。在J2EE中，这样的例子比比皆是。从实现EJB的安全性和事务性行为到描述JMS消息和目的地之间的关系，很多运行时的处理流程都是可以在程序之外定义的。<br /><br />　　Struts 创建者从一开始就采用这种方法，通过配置Struts的配置文件来定制应用系统运行时的各个方面。这一点在版本1.1的新特性上得到延续，包括新的异常处理功能。在Struts framework以前的版本中，开发人员不得不自己处理Struts应用中发生的错误情况。在最新的版本中，情况大大的改观了，Struts Framework提供了内置的一个称为 ExceptionHandler 的类， 用于系统缺省处理action类运行中产生的错误。这也是在上一个技巧中我们提到的framework许多可扩展接口之一。<br /><br />　　Struts缺省的 ExceptionHandler类会生成一个ActionError对象并保存在适当的范围（scope）对象中。这样就允许JSP页面使用错误类来提醒用户出现什么问题。如果你认为这不能满足你的需求，那么可以很方便的实现你自己的ExcepionHandler类。<br /><br />　　<b>具体定制异常处理的方法和机制</b><br /><br />　　要定制自己的异常处理机制，第一步是继承org.apache.struts.action.ExceptionHandler类。这个类有2个方法可以覆盖，一个是excute()另外一个是storeException(). 在多数情况下，只需要覆盖其中的excute()方法。下面是ExceptionHandler类的excute()方法声明：<br /><br /><table width="600" align="center"><tbody><tr><td><img height="157" src="http://www.yesky.com/SoftChannel/72342371961929728/20021203/jt-2002-1203-image001.gif" width="553" /></td></tr></tbody></table><br />　　正如你看到的，该方法有好几个参数，其中包括原始的异常。方法返回一个ActionForward对象，用于异常处理结束后将controller类带到请求必须转发的地方去。<br /><br />　　当然您可以实现任何处理，但一般而言，我们必须检查抛出的异常,并针对该类型的异常进行特定的处理。缺省的，系统的异常处理功能是创建一个出错信息，同时把请求转发到配置文件中指定的地方去。 定制异常处理的一个常见的例子是处理嵌套异常。假设该异常包含有嵌套异常，这些嵌套异常又包含了其他异常，因此我们必须覆盖原来的execute()方法，对每个异常编写出错信息。<br /><br />　　一旦你创建了自己的ExceptionHandler 类，就应该在Struts配置文件中的部分声明这个类，以便让Struts知道改用你自定义的异常处理取代缺省的异常处理. <br /><br />　　可以配置你自己的ExceptionHandler 类是用于Action Mapping特定的部分还是所有的Action对象。如果是用于Action Mapping特定的部分就在<action>元素中配置。如果想让这个类可用于所有的Action对象,可以在<global-sections> 元素中指定。例如，假设我们创建了异常处理类CustomizedExceptionHandler用于所有的Action类, <global-exceptions>元素定义如下所示：<br /><br /><table width="600" align="center"><tbody><tr align="middle"><td><img height="193" src="http://www.yesky.com/SoftChannel/72342371961929728/20021203/jt-2002-1203-image002.gif" width="193" /></td></tr></tbody></table><br />　　在<exception>元素中可以对很多属性进行设置。在本文中，最重要的属性莫过于handler属性, handler属性的值就是自定义的继承了ExceptionHandler类的子类的全名。 假如该属性没有定义，Struts会采用自己的缺省值。当然，其他的属性也很重要，但如果想覆盖缺省的异常处理的话，handler无疑是最重要的属性。<br /><br />　　最后必须指出的一点是，你可以有不同的异常处理类来处理不同的异常。在上面的例子中，CustomizedExceptionHandler用来处理任何java.lang.Exception的子类. 其实，你也可以定义多个异常处理类，每一个专门处理不同的异常树。下面的XML片断解释了如何配置以实现这一点。<br /><br /><table width="600" align="center"><tbody><tr align="middle"><td><img height="193" src="http://www.yesky.com/SoftChannel/72342371961929728/20021203/jt-2002-1203-image003.gif" width="193" /></td></tr></tbody></table><br />　　在这里，一旦有异常抛出，struts framework将试图在配置文件中找到ExceptionHandler，如果没有找到，那么struts将沿着该异常的父类链一层层往上找直到发现匹配的为止。因此，我们可以定义一个层次型的异常处理关系结构，在配置文件中已经体现了这一点。<br /></exception></global-exceptions></global-sections></action><img src ="http://www.blogjava.net/web/aggbug/59240.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-20 17:20 <a href="http://www.blogjava.net/web/archive/2006/07/20/experience7_1_struts.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[Struts]应用Map作为ActionForm的属性，动态增加ActionForm的“属性” （转）</title><link>http://www.blogjava.net/web/archive/2006/07/20/struts_actionform.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 20 Jul 2006 09:17:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/20/struts_actionform.html</guid><wfw:comment>http://www.blogjava.net/web/comments/59239.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/20/struts_actionform.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/59239.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/59239.html</trackback:ping><description><![CDATA[<div class="postTitle">
				<a class="postTitle2" id="viewpost1_TitleUrl" href="http://johnny.cnblogs.com/articles/169546.html">[Struts]应用Map作为ActionForm的属性，动态增加ActionForm的“属性”</a>
		</div>通常情况下，我们要在ActionForm中为相应表单定义对应的私有属性，再通过Getter和Setter设置和获得表单的数据。<br /><br />但如果表单数据域比较多，那么就需要在ActionForm中为每个表单域定义一个私有属性并定义相应的Getter、Setter方法。<br /><br />解决方法有两种，一种是在ActionForm中定义一个Map私有属性，动态产生表单提交的数据域；另一种是使用DynaActionForm。<br /><br />这里，我想以一个例子介绍一下第一种方法。<br /><br />首先创建ActionForm类：TestForm 
<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><span style="COLOR: #008080"> 1</span><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">package form;<br /></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />import org.apache.struts.action.ActionForm;<br /></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />import java.util.HashMap;<br /></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img id="Codehighlighter1_127_347_Open_Image" style="DISPLAY: inline" onclick="this.style.display='none'; Codehighlighter1_127_347_Open_Text.style.display='none'; Codehighlighter1_127_347_Closed_Image.style.display='inline'; Codehighlighter1_127_347_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_127_347_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_127_347_Closed_Text.style.display='none'; Codehighlighter1_127_347_Open_Image.style.display='inline'; Codehighlighter1_127_347_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> TestForm extends ActionForm </span><span id="Codehighlighter1_127_347_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.cnblogs.com/Images/dot.gif" /></span><span id="Codehighlighter1_127_347_Open_Text" style="DISPLAY: inline"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />  </span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000"> HashMap</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">String,Object</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> map </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> HashMap</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">String,Object</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">();<br /></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" /><br /></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img id="Codehighlighter1_236_265_Open_Image" onclick="this.style.display='none'; Codehighlighter1_236_265_Open_Text.style.display='none'; Codehighlighter1_236_265_Closed_Image.style.display='inline'; Codehighlighter1_236_265_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_236_265_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_236_265_Closed_Text.style.display='none'; Codehighlighter1_236_265_Open_Image.style.display='inline'; Codehighlighter1_236_265_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> Object getValue(String key) </span><span id="Codehighlighter1_236_265_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.cnblogs.com/Images/dot.gif" /></span><span id="Codehighlighter1_236_265_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> map.</span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">(key);<br /></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />  }</span></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" /><br /></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img id="Codehighlighter1_316_344_Open_Image" onclick="this.style.display='none'; Codehighlighter1_316_344_Open_Text.style.display='none'; Codehighlighter1_316_344_Closed_Image.style.display='inline'; Codehighlighter1_316_344_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_316_344_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_316_344_Closed_Text.style.display='none'; Codehighlighter1_316_344_Open_Image.style.display='inline'; Codehighlighter1_316_344_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> setValue(String key,Object value) </span><span id="Codehighlighter1_316_344_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.cnblogs.com/Images/dot.gif" /></span><span id="Codehighlighter1_316_344_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />    map.put(key,value);<br /></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />  }</span></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" /><br /></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div></div><br /><p>请注意第7行，这里定义了一个私有变量，该变量是一个Map类。<br />第9、13行分别定义了Getter和Setter方法，这里，Getter方法需要一个参数，用于传递表单域（即动态属性）的名称，Setter方法需要两个参数，分别是表单域名称和对应的值，这和传统的ActionForm的Getter和Setter有很大分别。<br /><br />然后创建Action类：TestAction<br /></p><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><span style="COLOR: #008080"> 1</span><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">package action;<br /></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />import org.apache.struts.action.Action;<br /></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />import org.apache.struts.action.ActionMapping;<br /></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />import org.apache.struts.action.ActionForm;<br /></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />import org.apache.struts.action.ActionForward;<br /></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />import java.util.HashMap;<br /></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />import javax.servlet.http.</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img id="Codehighlighter1_290_484_Open_Image" onclick="this.style.display='none'; Codehighlighter1_290_484_Open_Text.style.display='none'; Codehighlighter1_290_484_Closed_Image.style.display='inline'; Codehighlighter1_290_484_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_290_484_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_290_484_Closed_Text.style.display='none'; Codehighlighter1_290_484_Open_Image.style.display='inline'; Codehighlighter1_290_484_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> TestAction extends Action </span><span id="Codehighlighter1_290_484_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.cnblogs.com/Images/dot.gif" /></span><span id="Codehighlighter1_290_484_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img id="Codehighlighter1_435_482_Open_Image" onclick="this.style.display='none'; Codehighlighter1_435_482_Open_Text.style.display='none'; Codehighlighter1_435_482_Closed_Image.style.display='inline'; Codehighlighter1_435_482_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_435_482_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_435_482_Closed_Text.style.display='none'; Codehighlighter1_435_482_Open_Image.style.display='inline'; Codehighlighter1_435_482_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception </span><span id="Codehighlighter1_435_482_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.cnblogs.com/Images/dot.gif" /></span><span id="Codehighlighter1_435_482_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> mapping.findForward(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">success</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />  }</span></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div></div><p>第8行，鉴于这是一个例子为了简便起见使用了“*”代替了具体的类，编写程序时还是需要培养良好的习惯引入相应的类，避免出现冲突。<br />这个类很简单，只是把请求传递到一个在Struts中命名为“success”的forward对应的页面，具体请看下面列出的struts-config.xml当中的配置。<br /><br />然后是输入表单的JSP页面：input.jsp<br /></p><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><span style="COLOR: #008080">1</span><img id="Codehighlighter1_2_48_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2_48_Open_Text.style.display='none'; Codehighlighter1_2_48_Closed_Image.style.display='inline'; Codehighlighter1_2_48_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_2_48_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2_48_Closed_Text.style.display='none'; Codehighlighter1_2_48_Open_Image.style.display='inline'; Codehighlighter1_2_48_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /><span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">&lt;%</span><span id="Codehighlighter1_2_48_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.cnblogs.com/Images/dot.gif" /></span><span id="Codehighlighter1_2_48_Open_Text"><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">@ taglib 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">/tags/struts-html</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> 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"> </span></span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080">3</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">html:form </span><span style="COLOR: #ff0000">action</span><span style="COLOR: #0000ff">="/Test.do"</span><span style="COLOR: #ff0000"> method</span><span style="COLOR: #0000ff">="post"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">4</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />   </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">html:text </span><span style="COLOR: #ff0000">property</span><span style="COLOR: #0000ff">="value(a)"</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">5</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />   </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">html:text </span><span style="COLOR: #ff0000">property</span><span style="COLOR: #0000ff">="value(b)"</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">6</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />   </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">html:submit</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">Submit</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">html:submit</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">7</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/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></div></div><p><br />第1行引入了Struts的html标签库<br />请注意第4、5行，如果使用传统的ActionForm，property的值应该与ActionForm里面的一个私有属性的名称对应，但在这里，请回忆上述ActionForm中的Getter和Setter方法，分别带有一个参数和两个参数，这里的property会通过反射机制自动调用Setter方法，“value(a)”中的“value”就是ActionForm中Map的名称，而括号当中的“a”，就是我们动态产生的表单域的名称，它对应Getter方法中的第一个参数“key”，而用户在表单输入的值就对应Setter方法中的第二个参数“value”。<br /><br />这里，我们分别动态创建了两个名为“a”和“b”的表单域，存放到Map中。<br /><br />然后，我们看看success.jsp即Action转发到的页面</p><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><span style="COLOR: #008080">1</span><img id="Codehighlighter1_2_48_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2_48_Open_Text.style.display='none'; Codehighlighter1_2_48_Closed_Image.style.display='inline'; Codehighlighter1_2_48_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_2_48_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2_48_Closed_Text.style.display='none'; Codehighlighter1_2_48_Open_Image.style.display='inline'; Codehighlighter1_2_48_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /><span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">&lt;%</span><span id="Codehighlighter1_2_48_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.cnblogs.com/Images/dot.gif" /></span><span id="Codehighlighter1_2_48_Open_Text"><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">@ taglib 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">/tags/struts-bean</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> 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"> </span></span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080">3</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">bean:write </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="test"</span><span style="COLOR: #ff0000"> property</span><span style="COLOR: #0000ff">="value(a)"</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">4</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">bean:write </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="test"</span><span style="COLOR: #ff0000"> property</span><span style="COLOR: #0000ff">="value(b)"</span><span style="COLOR: #0000ff">/&gt;</span></div></div><p><br />第1行引入了Struts的bean标签库。<br />请注意第2行，引用了名为“test”的ActionForm（详细设置请看struts-config.xml）。这标签的作用是显示输出ActionForm的指定属性值。请注意property，“value”就是ActionForm中Map的名称，它通过反射机制自动调用ActionForm的Getter方法，请回忆上述ActionForm中的Getter方法，带有一个参数“key”，这里的“a”，“b”实际上是对应刚才输入页面动态产生的两个表单域属性名。这里实际是要显示名为“test”的ActionForm的名为“value”的Map类属性中的“key”分别为“a”和“b”的对应的“value”。<br /><br />通过这样的设计，我们就完成了动态产生表单域属性的功能，这个设计的好处是你并不需要修改ActionForm，就能随意设计你的表单域属性，也大大减少了ActionForm的编码量。<br /><br />最后，让我们来看看struts-config.xml中的相应配置（只列出相关配置片断）：</p><p> </p><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><span style="COLOR: #008080"> 1</span><img src="http://www.cnblogs.com/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"><br /></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />  <img src="http://www.cnblogs.com/Images/dot.gif" /><br /></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/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 /></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">form-bean </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="test"</span><span style="COLOR: #ff0000"> type</span><span style="COLOR: #0000ff">="form.TestForm"</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/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 /></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />  <img src="http://www.cnblogs.com/Images/dot.gif" /><br /></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/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 /></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />     </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">action </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="test"</span><span style="COLOR: #ff0000"> path</span><span style="COLOR: #0000ff">="/Test"</span><span style="COLOR: #ff0000"> type</span><span style="COLOR: #0000ff">="action.TestAction"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">forward </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="success"</span><span style="COLOR: #ff0000"> path</span><span style="COLOR: #0000ff">="/pages/success.jsp"</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/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 /></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/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 /></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />   <img src="http://www.cnblogs.com/Images/dot.gif" /><br /></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cnblogs.com/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></div></div><p> </p><img src ="http://www.blogjava.net/web/aggbug/59239.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-20 17:17 <a href="http://www.blogjava.net/web/archive/2006/07/20/struts_actionform.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>标签示例</title><link>http://www.blogjava.net/web/archive/2006/07/18/taglib_example.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Tue, 18 Jul 2006 05:18:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/18/taglib_example.html</guid><wfw:comment>http://www.blogjava.net/web/comments/58728.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/18/taglib_example.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/58728.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/58728.html</trackback:ping><description><![CDATA[<font face="新宋体">
				<font color="#3f7f5f">//web.xml<br /></font>
				<font color="#000000">&lt;?xml version=</font>
				<font color="#2a00ff">"1.0" </font>
				<font color="#000000">encoding=</font>
				<font color="#2a00ff">"UTF-8"</font>
				<font color="#000000">?&gt;</font>
				<br />
				<font color="#000000">&lt;!DOCTYPE web-app PUBLIC </font>
				<font color="#2a00ff">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</font>
				<br />
				<font color="#ffffff">  </font>
				<font color="#2a00ff">"http://java.sun.com/dtd/web-app_2_3.dtd"</font>
				<font color="#000000">&gt;</font>
				<br />
				<font color="#000000">&lt;web-app&gt;</font>
				<br />
				<font color="#ffffff">  </font>
				<font color="#000000">&lt;resource-ref&gt;</font>
				<br />
				<font color="#ffffff">    </font>
				<font color="#000000">&lt;res-ref-name&gt;jdbc/address&lt;/res-ref-name&gt;</font>
				<br />
				<font color="#ffffff">    </font>
				<font color="#000000">&lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;</font>
				<br />
				<font color="#ffffff">    </font>
				<font color="#000000">&lt;res-auth&gt;Container&lt;/res-auth&gt;</font>
				<br />
				<font color="#ffffff">  </font>
				<font color="#000000">&lt;/resource-ref&gt;</font>
				<br />
				<font color="#000000">&lt;/web-app&gt;</font>
				<br />
				<font color="#ffffff">
				</font>
				<br />
				<font color="#ffffff">
				</font>
				<br />
				<font color="#ffffff">
				</font>
				<br />
				<font color="#ffffff">
				</font>
				<br />
				<font color="#000000">&lt;%@ taglib prefix=</font>
				<font color="#2a00ff">"sql" </font>
				<font color="#000000">uri=</font>
				<font color="#2a00ff">"http://java.sun.com/jstl/sql" </font>
				<font color="#000000">%&gt;</font>
				<br />
				<font color="#000000">&lt;%@ taglib prefix=</font>
				<font color="#2a00ff">"c" </font>
				<font color="#000000">uri=</font>
				<font color="#2a00ff">"http://java.sun.com/jstl/core" </font>
				<font color="#000000">%&gt;</font>
				<br />
				<font color="#000000">&lt;</font>
				<font color="#7f0055">
						<b>html</b>
				</font>
				<font color="#000000">&gt;</font>
				<br />
				<font color="#000000">&lt;head&gt;</font>
				<br />
				<font color="#000000">&lt;title&gt;Presenting database content </font>
				<font color="#7f0055">
						<b>using </b>
				</font>
				<font color="#000000">tags&lt;/title&gt;</font>
				<br />
				<font color="#000000">&lt;sql:setDataSource</font>
				<br />
				<font color="#ffffff">  </font>
				<font color="#000000">dataSource=</font>
				<font color="#2a00ff">"jdbc/address"</font>
				<br />
				<font color="#ffffff">  </font>
				<font color="#000000">var=</font>
				<font color="#2a00ff">"conn"</font>
				<br />
				<font color="#000000">/&gt;</font>
				<br />
				<font color="#000000">&lt;/head&gt;</font>
				<br />
				<font color="#000000">&lt;</font>
				<font color="#7f0055">
						<b>body</b>
				</font>
				<font color="#000000">&gt;</font>
				<br />
				<font color="#ffffff">
				</font>
				<br />
				<font color="#000000">&lt;h1&gt;Address List&lt;/h1&gt;</font>
				<br />
				<font color="#000000">&lt;sql:query dataSource=</font>
				<font color="#2a00ff">"${conn}" </font>
				<font color="#000000">var=</font>
				<font color="#2a00ff">"addresses"</font>
				<font color="#000000">&gt;</font>
				<br />
				<font color="#ffffff">    </font>
				<font color="#000000">SELECT * FROM AddressList</font>
				<br />
				<font color="#000000">&lt;/sql:query&gt;</font>
				<br />
				<font color="#000000">&lt;table width=</font>
				<font color="#2a00ff">"90%" </font>
				<font color="#000000">border=</font>
				<font color="#2a00ff">"1"</font>
				<font color="#000000">&gt;</font>
				<br />
				<font color="#000000">&lt;tr&gt;</font>
				<br />
				<font color="#000000">&lt;!-- add the table column headings --&gt;</font>
				<br />
				<font color="#000000">&lt;c:forEach var=</font>
				<font color="#2a00ff">"columnName" </font>
				<font color="#000000">items=</font>
				<font color="#2a00ff">"${addresses.columnNames}"</font>
				<font color="#000000">&gt;</font>
				<br />
				<font color="#ffffff">  </font>
				<font color="#000000">&lt;th&gt; &lt;c:out value=</font>
				<font color="#2a00ff">"${columnName}"</font>
				<font color="#000000">/&gt; &lt;/th&gt;</font>
				<br />
				<font color="#000000">&lt;/c:forEach&gt;</font>
				<br />
				<font color="#000000">&lt;/tr&gt;</font>
				<br />
				<font color="#000000">&lt;!-- add the table rows from the result set --&gt;</font>
				<br />
				<font color="#000000">&lt;c:forEach var=</font>
				<font color="#2a00ff">"row" </font>
				<font color="#000000">items=</font>
				<font color="#2a00ff">"${addresses.rowsByIndex}"</font>
				<font color="#000000">&gt;</font>
				<br />
				<font color="#ffffff">  </font>
				<font color="#000000">&lt;tr&gt;</font>
				<br />
				<font color="#ffffff">    </font>
				<font color="#000000">&lt;c:forEach var=</font>
				<font color="#2a00ff">"column" </font>
				<font color="#000000">items=</font>
				<font color="#2a00ff">"${row}"</font>
				<font color="#000000">&gt;</font>
				<br />
				<font color="#ffffff">      </font>
				<font color="#000000">&lt;td&gt;&lt;c:out value=</font>
				<font color="#2a00ff">"${column}"</font>
				<font color="#000000">/&gt;&lt;/td&gt;</font>
				<br />
				<font color="#ffffff">    </font>
				<font color="#000000">&lt;/c:forEach&gt;</font>
				<br />
				<font color="#ffffff">  </font>
				<font color="#000000">&lt;/tr&gt;</font>
				<br />
				<font color="#000000">&lt;/c:forEach&gt;</font>
				<br />
				<font color="#000000">&lt;/table&gt;</font>
				<br />
				<font color="#000000">&lt;/</font>
				<font color="#7f0055">
						<b>body</b>
				</font>
				<font color="#000000">&gt;</font>
				<br />
				<font color="#000000">&lt;/</font>
				<font color="#7f0055">
						<b>html</b>
				</font>
				<font color="#000000">&gt;</font>
		</font><img src ="http://www.blogjava.net/web/aggbug/58728.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-18 13:18 <a href="http://www.blogjava.net/web/archive/2006/07/18/taglib_example.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts标签之浅入深出(转)</title><link>http://www.blogjava.net/web/archive/2006/07/18/struts_tag_lib.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Tue, 18 Jul 2006 04:50:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/18/struts_tag_lib.html</guid><wfw:comment>http://www.blogjava.net/web/comments/58726.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/18/struts_tag_lib.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/58726.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/58726.html</trackback:ping><description><![CDATA[Action和jsp的开发其实就是对Struts标签的运用.掌握标签的熟练程度决定了开发效率.初学者往往对某个数据表示或数据获取,束手无策.一个简单的问题浪费一两天时间也就不足为怪了.导致整个开发进度延后.外面的struts书籍介绍标签和数据传输原理都比较简单,下面我对标签技术和数据传输原理,进行全方位多角度的剖析.希望对各位有所帮助.以此为模版,将大大提高开发效率.以sample为机能名称.<br />①画面上有一text框,显现内容为某一数据表中的某一字段.那我们该如何设置和得到此数据呢?<br />SampleJsp:<br />  &lt;html:text name = "sampleForm" property="name" /&gt;<br />SampleForm.java: // form文件名必须和jsp中标签的name对应<br />  String name; // 必须和jsp中该项目的property一样<br />  public String getName() { return name; }<br />  public void setName(String name) { this.name = name;}<br />变量和方法名,不可以顺意.变量abcd,那方法名就是setAbcd和getAbcd.注意大小写.<br />jsp中的项目必然全部在form里面有所表示,当然反过来,form里的项目在jsp中不一定全部表示(可能有辅助动作的对象或验证)<br />SampleAction.java <br />  public ActionForward start(ActionMapping mapping,<br />  ActionForm argForm, HttpServletRequest req, HttpServletResponse res)<br />  throws Exception {<br />        SampleForm form = (SampleForm) argForm;<br />        String name = ………………other codes for get name from db<br />        // set name<br />        form.setName(name);<br />        // now text will show the name<br />  }<br />public ActionForward save(ActionMapping mapping,<br />  ActionForm argForm, HttpServletRequest req, HttpServletResponse res)<br />        throws Exception {<br />        SampleForm form = (SampleForm) argForm;<br />        // get name<br />        String name = form.getName();<br />        ………………other codes for save name<br />  }<br />jsp和form对应,action操作form,form其实起了传输数据的作用.这就是struts标签的核心原理.得到数据和设置数据没问题了,剩下的工作也就得心应手了.<br /><br />②再看一个处理标签的方法.画面上是一个明细一览表示(表).表示的是数据表user的相关数据(id,name).<br />SampleJsp: <br />  &lt;logic:present name="sampleForm" property="userList" &gt;<br />    &lt;logic:iterate id="user" name=" sampleForm " property="userList"&gt;<br />      &lt;tr&gt;<br />        &lt;td&gt;&lt;bean:write name="user" property="id" /&gt;&lt;/td&gt;<br />        &lt;td&gt;&lt;bean:write name="user" property="name" /&gt;&lt;/td&gt;<br />      &lt;/tr&gt;<br />    &lt;/logic:iterate&gt; <br />  &lt;/logic:present&gt;<br /><br />logic:present是逻辑判断,sampleForm中userList为空(无数据或null),下面的东东不显示.<br />logic:iterate是逻辑循环,userList有几条数据,就循环几次.<br /><br />&lt;bean:write name="user" property="id" /&gt;是lable标签,显示user这个对象(entity)的id属性.或者说显示数据表user中的一条记录中的id这个列.<br />User.java(就是entity,因为和业务密切,高达不开发,切记切记不可顺意修改.遇到设计有问题,QA日本)<br />    String id;<br />    public String getId() { return id; }<br />    public void setId(String id) { this.id = id; }<br />    String name;<br />    public String getName () { return name; }<br />    public void setName (String name) { this.name = name; }<br />看到这,是否觉得面熟啊,好象和FORM一样,但有点不一样,不一样在哪里,看下去后,自己感悟吧.<br />SampleForm.java: <br />    List userList;<br />    public List getUserList () { return userList; }<br />    public void setUserList (List userList) { this.userList = userList; }<br />form只要这些,那你会问,id和name,struts如何能得到呢?你不是说过jsp必须和form一样对应吗?不错,一一对应是肯定的. UserList信息已经包含了一切,还需要定义id和name吗?至于struts如何得到数据,那就看下面的action是如何处理的吧.<br />SampleAction.java <br />public ActionForward start(ActionMapping mapping,<br />  ActionForm argForm, HttpServletRequest req, HttpServletResponse res)<br />        throws Exception {<br />        SampleForm form = (SampleForm) argForm;<br />        ArrayList userList = new ArrayList();<br />        User user = new User();<br />        user.setId(1);<br />        user.setName(“name1”);<br />        userList.add(user);<br /><br />        User user = new User();<br />        user.setId(2);<br />        user.setName(“name2”); <br />        userList.add(user);<br />        <br />        // set userList<br />        form.setUserList(userList);<br />        // now table will show<br />  }<br />一切搞定.是不是很简单,但估计你还是有点晕.你还是想问我,id和name到底是如何设置的?<br />Action设置了userList就够了,它包含够多的信息了. struts看见了你设置了userList.它就知道了这个list里面都user(entity),useruser(entity)里面不是有很多get,set方法吗?<br /><br />再看下下面的东东.<br />&lt;logic:iterate id="user" name=" sampleForm " property="userList"&gt;<br />&lt;bean:write name="user" property="id" /&gt;<br />id=”user”,和name="user" 对应了,明白啥意思吗?.就象循环指明索引一样. property="id"就是要显示的这个索引对应的内容.Struts就是这样来认id和name的.<br /><br />③接下来,看一个加强版的table例子,在显示的明细一览,每一行前面加一个radio框,让用户选择哪个user.进行删除操作.<br />SampleJsp: <br />  &lt;logic:present name="sampleForm" property="userList" &gt;<br />  &lt;logic:iterate id="user" name=" sampleForm " property="userList"&gt;<br />  &lt;tr&gt;<br />    &lt;td&gt;<br />  &lt;html:radio name="sampleForm" property="selectedUserId" value="&lt;%=((jp.co.mhcb.obs.persis.entity.User)pageContext.getAttribute("user ")).getId().toString() %&gt;" /&gt;<br />   &lt;/td&gt;<br />   &lt;td&gt;&lt;bean:write name="user" property="id" /&gt;&lt;/td&gt;<br />   &lt;td&gt;&lt;bean:write name="user" property="name" /&gt;&lt;/td&gt;<br />  &lt;/tr&gt;<br />&lt;/logic:iterate&gt; <br />&lt;/logic:present&gt;<br /><br />sampleForm.java:<br />    String selectedUserId; <br />    public String getSelectedUserId () { return selectedUserId; }<br />    public void setSelectedUserId(String selectedUserId) {<br />        this.selectedUserId = selectedUserId;<br />    }<br />SampleAction.java <br />public ActionForward delete(ActionMapping mapping,<br />  ActionForm argForm, HttpServletRequest req, HttpServletResponse res)<br />        throws Exception {<br />        SampleForm form = (SampleForm) argForm;<br />        String selectedUserId = form.getSelectedUserId();<br />        // get user by selected id<br />        User user = getUser(selectedUserId);<br />        // delete user<br />        }<br />radio框. propertys值对应form里的对象.value值是该行radio对应的user中的id(数据表中user的id是主键),那么当用户选中任何一个radio,struts通过form得到propertys值,就可以得到选中哪个user了,然后进行相应操作.<br />设置哪个user被选中,一是通过用户选择,没的说.二,通过程序控制,如果进入初期画面,我要让user.id = ‘3’的radio被选中,只要在初期Action中form.selectedUserId(“3”);一切搞定,就一句话,进入初期画面时, user.id = ‘3’的radio被选中了.<br /><br />注意以下标签<br />&lt;html:radio name="sampleForm" property="selectedUserId" value="&lt;%= ((jp.co.mhcb.obs.persis.entity.User)pageContext.getAttribute("user ")).getId().toString() %&gt;" /&gt;<br />下面发挥想象一下以下标签啥意思?<br />&lt;html:radio name="sampleForm" property="selectedUserId" value="&lt;%= ((jp.co.mhcb.obs.persis.entity.User)pageContext.getAttribute("user ")).getObject1().getObject1().getObject2()…………getObjectN().getId().toString() %&gt;" /&gt;<br />能看出来什么?<br />User包含object1,object2包含object3,….objectN-1包含objectN,objectN有id属性.<br />看出来了吗?灵活运用,想象一下,各个entity和form,action该如何写?<br /><br />④接着介绍一下,checkbox是使用.画面有一排checkbox,如何设置和得到数据呢?先看一个简单点的. <br /> &lt;html:checkbox name=" sampleForm" property="chechbox1" value="true" /&gt;<br /> &lt;html:checkbox name=" sampleForm" property="chechbox2" value="false" /&gt;<br /> &lt;html:checkbox name=" sampleForm" property="chechbox3" value="true" /&gt;<br />第二个框未选中,其他选中.form里面对应三个String chechbox1,chechbox2, chechbox3;下面来个复杂点的,多选择对话框multibox<br />SampleJsp中：<br />&lt;logic:iterate name = "sampleForm" id="user" property="userList"&gt;<br />  &lt;html:multibox property="selectedUsers"&gt;<br />    &lt;bean:write name="user" property="id"/&gt; <br />  &lt;/html:multibox&gt;<br />  &lt;bean:write name="user" property="name"/&gt; <br />&lt;/logic:iterate&gt;<br /><br />SampleForm中:<br />    private String userList[] = new String[0]; <br />    public String[] getUserList () { return userList;}<br />    public void setUserList(String[]userList) {this.userList = userList;}<br /><br />    private String selectedUsers[] = new String[0];<br />    public String[] getSelectedUsers () {return selectedUsers;}<br />    public void setSelectedUsers (String[]selectedUsers) {this.selectedUsers = selectedUsers;}<br /><br />如果我们在初期时在action里对bean赋值：<br />userList = { User(”1”,”name1”), User(”2”, ”name2”), User(”3”,”name3”) }<br />selectedUsers = {“1”，”3”}<br />那画面选中第一第三个选择框.<br /><br />用户修改选择框,选择了第二,第三个,那么在action里取bean的值<br />String selectedItems[] = new String[list.getSize()];<br />selectedItems = form.getSelectedItems();<br />for ( int i = 0 ; i &lt; selectedItems.length ; ++i ){<br />  LOGGER.debug( "selected " + i + ": " + selectedItems[i]);<br />}<br />Selected 0 : 2 <br />Selected 1 : 3<br />selectedUsers = {“2”，”3”}<br /><br />⑤画面上有一user表,每条数据前面有个button,对应一条记录,如何确定选中那条数据呢??<br />SampleJsp:<br />&lt;logic:iterate id="user" indexId="buttonIndex" name="sampleForm" property="userList"&gt;<br />&lt;tr&gt;<br />&lt;td&gt;<br />&lt;html:submit property="button" indexed='false' &gt;<br />&lt;bean:message key="label.button.selectUser"/&gt;<br />&lt;/td&gt;<br />&lt;td&gt;&lt;bean:write name="user" property="id" /&gt;&lt;/td&gt;<br />&lt;td&gt;&lt;bean:write name="user" property="name" /&gt;&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;html:hidden name="sampleForm" property="selectUserIndex" value='&lt;%= "" + buttonIndex %&gt;'/&gt;<br />&lt;/logic:iterate&gt;<br /><br />SampleAction.java<br />   int index = Integer.parseInt(form.getSelectUserIndex());<br />   通过一个隐藏变量,得到选中第几条数据,然后就能做相应处理.<br /><br />⑥上面都是通过form和jsp传输数据的.还有session也能让jsp显示数据.但如果我做为设计者,是不提倡这样做的.为什么就不说了.但日本以前的设计很可能会用到session和jsp传数据.那我就有必要讲一下如何用了?做为高达的设计者还是尽量不要用session和jsp沟通.<br />有个下拉列表框,里面显示所有用户名称.用session传数据.<br />SampleJsp:<br />&lt;%pageContext.setAttribute("userList",(List) (FwThreadContext<br />                .getAttribute("AllUser")));<br />%&gt;<br />&lt;html:select property="selectedUser"&gt; <br />  &lt;html:options collection="userList" property="id" labelProperty="name" /&gt;<br />&lt;/html:select&gt;<br /><br />SampleForm.java:<br />    String selectedUser;<br />Form里只要一个selectedUser,表示选择的user. 下拉列表框用session表示.<br />在action等地方设置了session的内容,那下拉列表框就能显示内容了.这里session名为AllUser, labelProperty="name"是下拉列表框显示的东东, property="id"是下拉列表框每条数据隐藏的东东.通过property="selectedUser"里得到选中那条数据<br /><br />&lt;html:text name="sampleForm" property="name" <br />value="&lt;%= (FwThreadContext.getAttribute("UserName")).toString() %&gt;" /&gt;<br />这里很简单就是把session名为UserName设置到Text框中.得的时候还是通过form中的name得到.<br /><br /><br />标签宝典:<br />1,lable<br />&lt;bean:write name="sampleForm" property="name" /&gt;<br />2,text<br />&lt;html:text name="sampleForm " property="name" /&gt;<br />3,button<br />&lt;html:submit property="button"&gt;<br />&lt;bean:message key="label.button.save" /&gt;<br />&lt;/html:submit&gt;<br />&lt;html:button property="button" onclick="javascript:openCalendar(date);"&gt;<br />&lt;bean:message key="label.button.date" /&gt;<br />&lt;/html:button&gt;<br />4,select <br />&lt;html:select property="selectedUser"&gt; <br />  &lt;html:options name="sampleForm" collection="userList" property="id" labelProperty="name" /&gt;<br />&lt;/html:select&gt;<br />5,checkbox,multibox<br />  &lt;html:checkbox name="sampleForm" property="chechbox1" value="true" /&gt;<br />  <br />  &lt;logic:iterate name = "sampleForm" id="user" property="userList"&gt;<br />    &lt;html:multibox property="selectedUsers"&gt;<br />     &lt;bean:write name="user" property="id"/&gt; <br />    &lt;/html:multibox&gt;<br />    &lt;bean:write name="user" property="name"/&gt; <br />  &lt;/logic:iterate&gt;<br /><br />6, 循环逻辑<br />&lt;logic:present name="sampleForm" property="userList" &gt;<br />&lt;logic:iterate id="user" name=" sampleForm " property="userList"&gt;<br />&lt;tr&gt;<br />  &lt;td&gt;<br />  &lt;html:radio name="sampleForm" property="selectedUserId" value="&lt;%= ((jp.co.mhcb.obs.persis.entity.User)pageContext.getAttribute("user ")).getId().toString() %&gt;" /&gt;<br />  &lt;/td&gt;<br />  &lt;td&gt;&lt;bean:write name="user" property="id" /&gt;&lt;/td&gt;<br />  &lt;td&gt;&lt;bean:write name="user" property="name" /&gt;&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;/logic:iterate&gt; <br />&lt;/logic:present&gt;<br /><br />7,if逻辑<br />&lt;logic:equal name=" sampleForm " property="showAllFlg" value="true" &gt;<br />  &lt;html:submit property="button"&gt;<br />    &lt;bean:message key="label.button.all"/&gt;<br />  &lt;/html:submit&gt;<br />&lt;/logic:equal&gt;<br />&lt;logic:equal name=" sampleForm " property=" showAllFlg " value="false" &gt;<br />  &lt;html:submit property="button"&gt;<br />    &lt;bean:message key="label.button.noall"/&gt;<br />  &lt;/html:submit&gt;<br />&lt;/logic:equal&gt;<img src ="http://www.blogjava.net/web/aggbug/58726.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-18 12:50 <a href="http://www.blogjava.net/web/archive/2006/07/18/struts_tag_lib.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSTL语法及参数</title><link>http://www.blogjava.net/web/archive/2006/07/13/JSTL_GrammarAndParameter.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 13 Jul 2006 15:46:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/13/JSTL_GrammarAndParameter.html</guid><wfw:comment>http://www.blogjava.net/web/comments/58075.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/13/JSTL_GrammarAndParameter.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/58075.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/58075.html</trackback:ping><description><![CDATA[<strong>
				<span class="tpc_title">JSTL语法及参数</span>
				<br />
				<br />
		</strong>
		<span class="tpc_content">
				<font size="2">JSTL语法及参数<br />作者 胡祥春<br /><br />JSTL语法及参数<br />JSTL包含以下的标签:<br />常用的标签：如&lt;c:out&gt;、&lt;c:remove&gt;、&lt;c:catch&gt;、&lt;c:set&gt;等<br />条件标签：如&lt;c:if&gt;&lt;c:when&gt;、&lt;c:choose&gt;、&lt;c:otherwise&gt;等<br />URL标签：如&lt;c:import&gt;、&lt;c:redirect&gt;和&lt;c:url&gt;等<br />XML标签：如&lt;xml:out&gt;等<br />国际化输出标签：如&lt;fmt:timeZone&gt;等<br />SQL标签：如&lt;sql:query&gt;、&lt;sql:update&gt;、&lt;sql:transaction&gt;等<br /><br /><br />一般用途的标签: <br />1．&lt;c:out&gt; <br />没有Body时的语法 <br />&lt;c:out value=”value” [escapeXml=”{true|false}”] [default=”defaultValue”]/&gt; <br />有Body时的语法 <br />&lt;c:out value=”value” [escapeXml=”{true|false}”]&gt; <br />这里是Body部分 <br />&lt;/c:out&gt; <br /><br /><br /><br />名字 类型 描述 <br />value Object 将要输出的表达式 <br />escapeXml boolean 确定以下字符:&lt;,&gt;,<br /></font>
		</span>
		<br />
		<br />From:http://www.xin7dian.com/read.php?tid=1973<img src ="http://www.blogjava.net/web/aggbug/58075.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-13 23:46 <a href="http://www.blogjava.net/web/archive/2006/07/13/JSTL_GrammarAndParameter.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts常见错误汇总(转)</title><link>http://www.blogjava.net/web/archive/2006/07/06/struts_errors.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 06 Jul 2006 07:49:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/06/struts_errors.html</guid><wfw:comment>http://www.blogjava.net/web/comments/56963.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/06/struts_errors.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/56963.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/56963.html</trackback:ping><description><![CDATA[以下所说的struts-config.xml和ApplicationResources.properties等文件名是缺省时使用的，如果你使用了多模块，或指定了不同的资源文件名称，这些名字要做相应的修改。 
<p>　　<strong>1、“No bean found under attribute key XXX”</strong><br />　　在struts-config.xml里定义了一个ActionForm，但type属性指定的类不存在，type属性的值应该是Form类的全名。或者是，在Action的定义中，name或attribute属性指定的ActionForm不存在。</p><p>　　<strong>2、“Cannot find bean XXX in any scope”</strong><br />　　在Action里一般会request.setAttribute()一些对象，然后在转向的jsp文件里（用tag或request.getAttribute()方法）得到这些对象并显示出来。这个异常是说jsp要得到一个对象，但前面的Action里并没有将对象设置到request（也可以是session、servletContext）里。<br />可能是名字错了，请检查jsp里的tag的一般是name属性，或getAttribute()方法的参数值；或者是Action逻辑有问题没有执行setAttribute()方法就先转向了。<br />还有另外一个可能，纯粹是jsp文件的问题，例如&lt;logic:iterate&gt;会指定一个id值，然后在循环里&lt;bean:write&gt;使用这个值作为name的值，如果这两个值不同，也会出现此异常。（都是一个道理，request里没有对应的对象。）</p><p>　　<strong>3、“Missing message for key "XXX"”</strong><br />　　缺少所需的资源，检查ApplicationResources.properties文件里是否有jsp文件里需要的资源，例如：<br />　　&lt;bean:message key="msg.name.prompt"/&gt;<br />　　这行代码会找msg.name.prompt资源，如果AppliationResources.properties里没有这个资源就会出现本异常。在使用多模块时，要注意在模块的struts-config-xxx.xml里指定要使用的资源文件名称，否则当然什么资源也找不到，这也是一个很容易犯的错误。</p><p>　　<strong>4、“No getter method for property XXX of bean teacher”</strong><br />　　这条异常信息说得很明白，jsp里要取一个bean的属性出来，但这个bean并没有这个属性。你应该检查jsp中某个标签的property属性的值。例如下面代码中的cade应该改为code才对：<br />　　&lt;bean:write name="teacher" property="cade" filter="true"/&gt;</p><p>　　<strong>5、“Cannot find ActionMappings or ActionFormBeans collection”</strong><br />　　待解决。</p><p>　　<strong>6、“Cannot retrieve mapping for action XXX”</strong><br />　　在.jsp的&lt;form&gt;标签里指定action='/XXX'，但这个Action并未在struts-config.xml里设置过。</p><p>　　<strong>7、HTTP Status 404 - /xxx/xxx.jsp</strong><br />　　Forward的path属性指向的jsp页面不存在，请检查路径和模块，对于同一模块中的Action转向，path中不应包含模块名；模块间转向，记住使用contextRelative="true"。</p><p>　　<strong>8、没有任何异常信息，显示空白页面<br /></strong>　　可能是Action里使用的forward与struts-config.xml里定义的forward名称不匹配。</p><p>　　<strong>9、“The element type "XXX" must be terminated by the matching end-tag "XXX".”</strong><br />　　这个是struts-config.xml文件的格式错误，仔细检查它是否是良构的xml文件，关于xml文件的格式这里就不赘述了。</p><p>　　<strong>10、“Servlet.init() for servlet action threw exception”<br /></strong>　　一般出现这种异常在后面会显示一个关于ActionServlet的异常堆栈信息，其中指出了异常具体出现在代码的哪一行。我曾经遇到的一次提示如下：</p><p>　　java.lang.NullPointerException<br />　　　at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:1003)<br />　　　at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:955)</p><p>　　为解决问题，先下载struts的源码包，然后在ActionServlet.java的第1003行插入断点，并对各变量进行监视。很丢人，我竟然把struts-config.xml文件弄丢了，因此出现了上面的异常，应该是和CVS同步时不小心删除的。</p><p>　　<strong>11、“Resources not defined for Validator”</strong><br />　　这个是利用Validator插件做验证时可能出现的异常，这时你要检查validation.xml文件，看里面使用的资源是否确实有定义，form的名称是否正确，等等。<br /><br /><br />来源:http://blog.csdn.net/jht2002/</p><img src ="http://www.blogjava.net/web/aggbug/56963.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-06 15:49 <a href="http://www.blogjava.net/web/archive/2006/07/06/struts_errors.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>什么是ERP软件</title><link>http://www.blogjava.net/web/archive/2006/07/04/WhatIsERP.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Mon, 03 Jul 2006 23:16:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/04/WhatIsERP.html</guid><wfw:comment>http://www.blogjava.net/web/comments/56440.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/04/WhatIsERP.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/56440.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/56440.html</trackback:ping><description><![CDATA[<p>什么是ERP软件?</p>
		<p>ERP是英文Enterprise Resourse Planning的缩写，中文意思是企业资源规划。它是一个以管理会计为核心的信息系统，识别和规划企业资源，从而获取客户订单，完成加工和交付，最后得到客户付款。换言之，ERP将企业内部所有资源整合在一起，对采购、生产、成本、库存、分销、运输、财务、人力资源进行规划，从而达到最佳资源组合，取得最佳效益。 </p>
		<p>企业资源规划 ERP, Enterprise Resource Planning）的合理运用已经改变了企业运作的面貌。ERP通过运用最佳业务制度规范business practice以及集成企业关键业务流程business processes来发问和提高企业利润，市场需求反应速度和企业。 </p>
		<p>同时，企业处在日新月异的市场机遇、价格和服务水平等的挑战环境中，必须不断改变、改善企业经营模式，提高企业竞争力。以往仅仅关注于企业内部的流程改善，产品开发和制造水平的提高已经不足以面对现时的市场环境。事实说明，处在现代竞争环境的企业要保持生存和持续发展必须与商业合作伙伴充分协调一以建立一个具有竞争优势的价值链。 <br /></p><img src ="http://www.blogjava.net/web/aggbug/56440.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-04 07:16 <a href="http://www.blogjava.net/web/archive/2006/07/04/WhatIsERP.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>毕业课程设计（新）：网上图书销售系统</title><link>http://www.blogjava.net/web/archive/2006/07/03/BookStoreOnWeb.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Mon, 03 Jul 2006 13:05:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/07/03/BookStoreOnWeb.html</guid><wfw:comment>http://www.blogjava.net/web/comments/56411.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/07/03/BookStoreOnWeb.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/56411.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/56411.html</trackback:ping><description><![CDATA[java课程设计改题目了。上次公布有误。<br />毕业设计：网上图书销售系统<br />使用struts按需求完成资产管理系统<br />时间：20060703--20060731<br />开发人员：5人 <br /><font face="宋体">总体需求描述</font><p class="25" style="MARGIN: 0cm 0cm 0pt 29.9pt"><font face="宋体"><span lang="EN-US">1</span>）客户可以通过多种方式查询，并且挑选网上图书公司的所有出售书籍。通过在网上填写并确认购书订单的方式来购买图书。</font></p><p class="25" style="MARGIN: 0cm 0cm 0pt 29.9pt"><font face="宋体"><span lang="EN-US">2</span>）客户可以管理自己的订单信息，查询汇款单信息，并且可以在网上留言反馈意见等。</font></p><p class="25" style="MARGIN: 0cm 0cm 0pt 29.9pt"><font face="宋体"><span lang="EN-US">3</span>）企业可以对图书信息进行管理。</font></p><p class="25" style="MARGIN: 0cm 0cm 0pt 29.9pt"><font face="宋体"><span lang="EN-US">4</span>）企业可以对图书的库存、订单和汇款单进行管理。</font></p><p class="25" style="MARGIN: 0cm 0cm 0pt 29.9pt"><font face="宋体"><span lang="EN-US">5</span>）企业可以对客户的订单信息，汇款单信息进行审核，以确定是否发货。</font></p><p class="25" style="MARGIN: 0cm 0cm 0pt 29.9pt"><font face="宋体"><span lang="EN-US">6</span>）企业可以针对客户意见录入处理结果。</font></p><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">      7</span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">）用户通过个性化服务可以自助注册和管理自己的个人信息<br />欢迎源代码交流</span><img src ="http://www.blogjava.net/web/aggbug/56411.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-07-03 21:05 <a href="http://www.blogjava.net/web/archive/2006/07/03/BookStoreOnWeb.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>集成新版本Tomcat到JBuilder</title><link>http://www.blogjava.net/web/archive/2006/06/29/TomcatInJbuilder.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 29 Jun 2006 12:14:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/06/29/TomcatInJbuilder.html</guid><wfw:comment>http://www.blogjava.net/web/comments/55814.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/06/29/TomcatInJbuilder.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/55814.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/55814.html</trackback:ping><description><![CDATA[
		<p class="bodySubTitle">Overview</p>
		<!-- Enter Appropriate Article Summary Here -->
		<p class="bodyText">Step-by-step procedure for integrating Tomcat 5 with JBuilder X</p>
		<p class="bodySubTitle">Details</p>
		<!-- Enter Appropriate Article Details Here -->
		<blockquote>
				<p class="bodyText">
						<em>Note:</em>
				</p>
				<p class="bodyText">
						<em>This is not a supported or tested configuration. This is just a workaround to get the server running in JBuilder X. JSP debugging will not work with this solution.</em>
						<br />
				</p>
				<p class="bodyText">Steps: </p>
				<blockquote>
						<p class="bodyText">1. Tools | Configure Servers, select the Tomcat 4.1 server and click the Copy button. Change the name to Tomcat 5.0. Next, set the home directory to the root of the Tomcat 5.0 installation, and remove the entry in the Class list and add &lt;TOMCAT_5.0_HOME&gt;/bin/bootstrap.jar.</p>
						<p class="bodyText"> </p>
						<p class="bodyText">2. File | New Project. Set server to Tomcat 5.0 and create a web module. This will trigger generation of the Tomcat 5.0 Servlet library.</p>
						<p class="bodyText"> </p>
						<p class="bodyText">3. Tools | Configure Libraries. Edit the Tomcat 5.0 Servlet library and add the following jars :</p>
						<blockquote>
								<p class="bodyText">&lt;TOMCAT_5.0_HOME&gt;/common/lib/jsp-api.jar<br />&lt;TOMCAT_5.0_HOME&gt;/common/lib/servlet-api.jar<br />&lt;TOMCAT_5.0_HOME&gt;/bin/commons-logging-api.jar<br />&lt;TOMCAT_5.0_HOME&gt;/common/lib/commons-el.jar</p>
						</blockquote>
						<p class="bodyText">Make a backup of this library (in your user home directory) as it gets regenerated when you create a new web module/JSP/servlet. Please make sure that you replace the library when you use any of the web gallery wizards.</p>
						<p class="bodyText"> </p>
						<p class="bodyText">4. Set server for the project to Tomcat 5.0.</p>
						<p class="bodyText"> </p>
						<p class="bodyText">5. If a "Tomcat" folder is not present under the project's root directory, create one (e.g. ../jbproject/untitled1/Tomcat). Next, create a directory named "conf" under this directory (e.g. ../jbproject/untitled1/Tomcat/conf). and create an XML file named server8080.xml. Sample server8080.xml is below. Please modify the appBase, docBase, and workDir, etc. according to your web module properties:</p>
						<p class="bodyText"> </p>
						<blockquote>
								<p class="bodyText">
										<em>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />&lt;!--This comment marks this file as generated, so it may be deleted and regenerated at any time. To preserve manual changes to this file, delete this comment.--&gt;<br />&lt;Server debug="0" port="8081" shutdown="SHUTDOWN"&gt;<br />&lt;Service name="Catalina"&gt;<br />&lt;Connector acceptCount="10" connectionTimeout="60000" debug="0" maxThreads="75" minSpareThreads="5" port="8080"/&gt;<br />&lt;Engine debug="0" defaultHost="localhost" name="Catalina"&gt;<br />&lt;Host appBase="C:Documents and Settings&lt;user name&gt;jbprojectuntitled1Tomcatwebapps" debug="0" name="localhost" unpackWARs="true"&gt;<br />&lt;Context debug="0" docBase="C:Documents and Settings&lt;user name&gt;jbprojectuntitled1WebModule1" path="/WebModule1" reloadable="true" workDir="C:Documents and Settings&lt;user name&gt;jbprojectuntitled1TomcatworkWebModule1"/&gt;<br />&lt;/Host&gt;<br />&lt;/Engine&gt;<br />&lt;/Service&gt;<br />&lt;/Server&gt;</em>
								</p>
						</blockquote>
						<p class="bodyText"> </p>
						<p class="bodyText">6. Start the server in JBuilder. This should use the modified server8080.xml</p>
						<p class="bodyText"> </p>
				</blockquote>
				<p class="bodyText">You should be able to compile JSPs using this workaround but not debug. You should be able to debug any java code. You will see a number of exceptions for the admin, manager, balancer services which do not get started when you normally run the server in JBuilder. Please ignore these exceptions. The server should function normally without these services.</p>
		</blockquote>
<img src ="http://www.blogjava.net/web/aggbug/55814.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-06-29 20:14 <a href="http://www.blogjava.net/web/archive/2006/06/29/TomcatInJbuilder.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>毕业课程设计：资产管理系统</title><link>http://www.blogjava.net/web/archive/2006/06/29/Struts.html</link><dc:creator>Hilly</dc:creator><author>Hilly</author><pubDate>Thu, 29 Jun 2006 12:05:00 GMT</pubDate><guid>http://www.blogjava.net/web/archive/2006/06/29/Struts.html</guid><wfw:comment>http://www.blogjava.net/web/comments/55812.html</wfw:comment><comments>http://www.blogjava.net/web/archive/2006/06/29/Struts.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/web/comments/commentRss/55812.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/web/services/trackbacks/55812.html</trackback:ping><description><![CDATA[毕业设计：资产管理系统<br />使用struts按需求完成资产管理系统<br />时间：20060701--20060731<br />开发人员：5人<img src ="http://www.blogjava.net/web/aggbug/55812.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/web/" target="_blank">Hilly</a> 2006-06-29 20:05 <a href="http://www.blogjava.net/web/archive/2006/06/29/Struts.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>