﻿<?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-J2EE剑侠行</title><link>http://www.blogjava.net/heweiya/</link><description>直觉我的J2EE应用生涯，打造我心中的一把利剑。</description><language>zh-cn</language><lastBuildDate>Fri, 01 May 2026 10:20:08 GMT</lastBuildDate><pubDate>Fri, 01 May 2026 10:20:08 GMT</pubDate><ttl>60</ttl><item><title>找到一个好用的UML建模工具-argouml</title><link>http://www.blogjava.net/heweiya/archive/2007/06/20/125328.html</link><dc:creator>@家军</dc:creator><author>@家军</author><pubDate>Wed, 20 Jun 2007 05:29:00 GMT</pubDate><guid>http://www.blogjava.net/heweiya/archive/2007/06/20/125328.html</guid><wfw:comment>http://www.blogjava.net/heweiya/comments/125328.html</wfw:comment><comments>http://www.blogjava.net/heweiya/archive/2007/06/20/125328.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/heweiya/comments/commentRss/125328.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/heweiya/services/trackbacks/125328.html</trackback:ping><description><![CDATA[&nbsp;很不错的一个UML建模工具-argouml<br>
&nbsp;&nbsp;&nbsp;&nbsp; <a  href="http://argouml-downloads.tigris.org/nonav/argouml-0.24/ArgoUML-0.24.zip">argouml下载地址</a><br>
&nbsp;&nbsp;&nbsp;&nbsp; 我一眼就看上他的原因是：生成的用例和包图可能直接生成JAVA代码，而且准备无误，这正是我要找的。<br>
&nbsp;&nbsp;&nbsp;&nbsp;
我想:以后使用一些框架的话，可能由PD生成一些实体,然后Hibernate生成pojo等,加入到argouml,然后根据一个框架的特性生成一些包
和类.就等于详细设计了吧.应该来说是比详细设计还实用的东西.总比哪些WORD文档好吧.还有让人看不懂的概要设计.<br>
&nbsp;&nbsp;&nbsp; 我想从技术出发,这个是一条比较适用的路子.下班了.我明天将会汇报一下我使用的情况和一些范例.<br>
&nbsp;&nbsp;&nbsp; 反过来又想像.这好象是一个组合的脚手架.好象ROR的零星操作步骤.应该学习.ROR毕竟是一个新生事物,JAVAEYE的推广也需要一个时间.如果像我这样的打工,混口饭吃的人还是专心的研究J2EE好一点.否则明天就没有饭吃了.<br>
<br>
&nbsp;&nbsp;&nbsp; 呵呵.我的文章可被JAVAEYE收回到水贴里了，可能自己的能力不如人吧，好好学习，天天向上，如果看客有什么好的工具和软件生产思路，可以共同交流。<br><img src ="http://www.blogjava.net/heweiya/aggbug/125328.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/heweiya/" target="_blank">@家军</a> 2007-06-20 13:29 <a href="http://www.blogjava.net/heweiya/archive/2007/06/20/125328.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> ROR:习惯约定优于配置(学习ROR的第一天)   </title><link>http://www.blogjava.net/heweiya/archive/2006/09/29/72764.html</link><dc:creator>@家军</dc:creator><author>@家军</author><pubDate>Fri, 29 Sep 2006 03:47:00 GMT</pubDate><guid>http://www.blogjava.net/heweiya/archive/2006/09/29/72764.html</guid><wfw:comment>http://www.blogjava.net/heweiya/comments/72764.html</wfw:comment><comments>http://www.blogjava.net/heweiya/archive/2006/09/29/72764.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/heweiya/comments/commentRss/72764.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/heweiya/services/trackbacks/72764.html</trackback:ping><description><![CDATA[
		<p>    今天学习了一下ROR，有一些学习经验东西要与大家分享。
<br />    给ROR加一个座右铭--------狭窄心肠的日本产物。
<br />    首先，不要一个一个的下载Ruby,Rails,建议使用一键安装，下载地址如下：
<br /><a href="http://rubyforge.org/frs/download.php/9731/InstantRails-1.3-win.zip" target="blank">InstantRails-1.3-win</a><br />   版本说明：ruby 1.8.4 (2005-12-24) [i386-mswin32]
<br />   其次，下载一个目前为止比较好的一个ROR的实践工具：RadRails
<br />   下载地址：<a href="http://nchc.dl.sourceforge.net/sourceforge/radrails/radrails-0.7.1-win32.zip" target="blank">radrails-0.7.1-win32</a><br />   接下来，设置一下Radrails的环境
<br />   1)、Windows/perferences/Ruby/Installed Inteperters/ -&gt;add ruby所在路径：比如D:\InstantRails\ruby\bin\ruby.exe
<br />   2)、Windows/perferences/Rails/Configuration -&gt;Rails path：比如D:\InstantRails\ruby\bin\rails
<br />                                               -&gt;Rake path:比如D:\InstantRails\ruby\bin\rake 绝不是bat/cmd
<br />                                               -&gt;mogrel path:比如D:\InstantRails\ruby\bin\mongrel_rails绝不是bat/cmd</p>
		<p>    有了如上的配置后，就只需要和在JAVA当中ANT一样使用。(成功用过APPFUSE的人就不用害怕了)
<br /><br />    看看日本人写的第一步:
<br />    1),在RadRails中创建一个Rails Project，怎么样会出来一堆的东东。
<br />    2),进入DOS命令吧，后面的工序都是这样的，好象买了海尔的洗衣机，第一次是送货、第二次是用户回访，第三次是.....
<br />       进入到你的项目处，运行ruby script\generate controller MyTest，
<br />       则得到的服务如下：
<br />      exists  app/controllers/
<br />      exists  app/helpers/
<br />      create  app/views/my_test
<br />      exists  test/functional/
<br />      create  app/controllers/my_test_controller.rb
<br />      create  test/functional/my_test_controller_test.rb
<br />      create  app/helpers/my_test_helper.rb
<br />      修改一下my_test_controller.rb
<br /></p>
		<div class="code_title">代码</div>
		<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">
				<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
				<span style="color: rgb(0, 0, 0);">      </span>
				<span style="color: rgb(0, 0, 255);">class</span>
				<span style="color: rgb(0, 0, 0);"> MyTestController </span>
				<span style="color: rgb(0, 0, 0);">&lt;</span>
				<span style="color: rgb(0, 0, 0);"> ApplicationController<br />      def index<br />        render_text </span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">Hello world!!</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">
						<br />      end <br />      end</span>
		</div>
		<br />      在浏览器里输入：http://127.0.0.1:3000/my_test/
<br />      会出现 Hello world!!字样，
<br />      不过有意思的是你可以输入：http://127.0.0.1:3000/My_test/
<br />      http://127.0.0.1:3000/My_Test/
<br />      http://127.0.0.1:3000/my_Test/
<br />      都可以得到这个值，可能没有JAVA哪样严格吧。
<br />     3)、还有对数据库的操作，要配置一个database.yml(好象Log4j的东东)
<br />     4)、创建数据库表的时候只能够使用复数起名，比如User就不行，只能够起Users
<br />         下面只要执行几个命令就可以使用增删改查了。
<br />         如下是我的操作，下班了，就不多写了，例子能够说明一切问题：
<br /><div class="code_title">代码</div><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 0);">E:\RORProject\demo</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">ruby script</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">generate model user<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">      exists  app</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">models</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">      exists  test</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">unit</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">      exists  test</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">fixtures</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">      create  app</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">models</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">user.rb<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">      create  test</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">unit</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">user_test.rb<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">      create  test</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">fixtures</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">users.yml<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">      exists  db</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">migrate<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">      create  db</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">migrate</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">001_create_users.rb<br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">E:\RORProject\demo</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">ruby script</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">generate controller user<br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);">exists app</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">controllers</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">exists app</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">helpers</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);">create app</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">views</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">user<br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">exists test</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">functional</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);">create app</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">controllers</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">user_controller.rb<br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);">create test</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">functional</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">user_controller_test.rb<br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">create app</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">helpers</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">user_helper.rb<br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);"></span></div><br />     修改user_controller.rb如下：
<br /><div class="code_title">代码</div><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">1</span> <span style="color: rgb(0, 0, 0);">   </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> UserController </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> ApplicationController<br /></span><span style="color: rgb(0, 128, 128);">2</span> <span style="color: rgb(0, 0, 0);">       scaffold:user<br /></span><span style="color: rgb(0, 128, 128);">3</span> <span style="color: rgb(0, 0, 0);">   end</span></div><br />  最后你的浏览器当中输入:http://127.0.0.1:3000/user/list,就包括了对数据库表的四个操作.当然你也可以自己定义四个操作的任意一种.

     <span style="color: red;"><br />最后总结：
<br />          ROR可能是敏捷开发的一个好实践，但是我觉得他完成复杂应用进不会有大做为，而至于这一点还需要再做探究。不过现阶段最好的需求就是能够给用户快速的写出一个不完整的DEMO，这一点为以后打单取得主动。
</span><img src ="http://www.blogjava.net/heweiya/aggbug/72764.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/heweiya/" target="_blank">@家军</a> 2006-09-29 11:47 <a href="http://www.blogjava.net/heweiya/archive/2006/09/29/72764.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>三个JAVA文件完成你的MVC应用</title><link>http://www.blogjava.net/heweiya/archive/2006/09/29/72760.html</link><dc:creator>@家军</dc:creator><author>@家军</author><pubDate>Fri, 29 Sep 2006 03:43:00 GMT</pubDate><guid>http://www.blogjava.net/heweiya/archive/2006/09/29/72760.html</guid><wfw:comment>http://www.blogjava.net/heweiya/comments/72760.html</wfw:comment><comments>http://www.blogjava.net/heweiya/archive/2006/09/29/72760.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/heweiya/comments/commentRss/72760.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/heweiya/services/trackbacks/72760.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 只需要你三个JAVA类和两个配置文件，就可以完成你的MVC应用，我们就做一个示例吧。本文以一个登录为例。第一个JAVA文件Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->/**======================================...&nbsp;&nbsp;<a href='http://www.blogjava.net/heweiya/archive/2006/09/29/72760.html'>阅读全文</a><img src ="http://www.blogjava.net/heweiya/aggbug/72760.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/heweiya/" target="_blank">@家军</a> 2006-09-29 11:43 <a href="http://www.blogjava.net/heweiya/archive/2006/09/29/72760.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts标签,请你走开(系列一)</title><link>http://www.blogjava.net/heweiya/archive/2006/09/25/71782.html</link><dc:creator>@家军</dc:creator><author>@家军</author><pubDate>Mon, 25 Sep 2006 08:36:00 GMT</pubDate><guid>http://www.blogjava.net/heweiya/archive/2006/09/25/71782.html</guid><wfw:comment>http://www.blogjava.net/heweiya/comments/71782.html</wfw:comment><comments>http://www.blogjava.net/heweiya/archive/2006/09/25/71782.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/heweiya/comments/commentRss/71782.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/heweiya/services/trackbacks/71782.html</trackback:ping><description><![CDATA[
		<p>   在项目开发的很多时候，用户需要更友好，更容易理解的操作界面，而为了能够达到这种表现界面，struts标签显得力不从心，本人经过几个项目的开发当中 逐渐的摈弃了struts标签，而由JSTL来做为JSP页面的表达者。
<br />   struts标签之死穴一  不支持嵌套
<br />   看看这种常见的需求吧。一个用户隶属于一个职能部门，比如
<br />   项目要求   职能部门有五个(乱写的)
<br />              1、企划部
<br />              2、网络集成部
<br />              3、行政部
<br />              4、营销部
<br />              5、产品部
<br />   项目要求   一共有二个员工
<br />              1、张三          隶属于行政部
<br />              2、李四          隶属于营销部
<br />   而你想把张三和李四都列表出来，显示为如下：
<br />      姓名        部门名称
<br />      张三        行政部
<br />      李四        营销部
<br />   而且还需要用户的列表链接到修改页面当中(假如只修改部门)应该如何做呢。
<br />   在使用struts标签是很难做到的，除非你非常不在意内存的使用(乱写技术性代码)
<br />看看JSTL是如何做的吧。
<br />   从STRUTS的ACTION当中加载两个对象</p>
		<p>
				<span class="constant">
				</span>
				<span class="punct">
				</span>
		</p>
		<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">
				<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
				<span style="color: rgb(0, 0, 0);">List GetAllDept </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);"> UserDAO.GetAllDept();</span>
				<span style="color: rgb(0, 128, 0);">//</span>
				<span style="color: rgb(0, 128, 0);">取得所有部门</span>
				<span style="color: rgb(0, 128, 0);">
						<br />
				</span>
				<span style="color: rgb(0, 0, 0);">
						<br />List GetALLUser </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);"> UserDAO.GetAllUser();</span>
				<span style="color: rgb(0, 128, 0);">//</span>
				<span style="color: rgb(0, 128, 0);">取得所有用户</span>
				<span style="color: rgb(0, 128, 0);">
						<br />
				</span>
				<span style="color: rgb(0, 0, 0);">
						<br />request.setAttribute(</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">View_Dept</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">, GetAllDept);<br /><br />request.setAttribute(</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">View_User</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">, GetALLUser);</span>
		</div>在页面当中加入对JSTL的引用<span class="regex"></span><div class="code_div"><pre><span class="string"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">&lt;%</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">@ taglib uri</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">http://java.sun.com/jsp/jstl/core</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);"> prefix</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">c</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">%&gt;</span></div><br /><span class="normal"></span></span>然后写代码如下：<br /></pre></div><div class="code_div"><pre><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">table</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">td </span><span style="color: rgb(255, 0, 0);">align</span><span style="color: rgb(0, 0, 255);">="center"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">a </span><span style="color: rgb(255, 0, 0);">href</span><span style="color: rgb(0, 0, 255);">="User.do?method=EditUser&amp;UserId=&lt;c:out value='${View_User.UserId}'/&gt;"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:out </span><span style="color: rgb(255, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">="${View_User.UserName}"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">a</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">td </span><span style="color: rgb(255, 0, 0);">align</span><span style="color: rgb(0, 0, 255);">="center"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:forEach </span><span style="color: rgb(255, 0, 0);">items</span><span style="color: rgb(0, 0, 255);">="${View_Dept}"</span><span style="color: rgb(255, 0, 0);"> var</span><span style="color: rgb(0, 0, 255);">="View_Dept"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:if </span><span style="color: rgb(255, 0, 0);">test</span><span style="color: rgb(0, 0, 255);">="${View_User.Dept.DeptId==View_Dept.DeptId}"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:out </span><span style="color: rgb(255, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">="${View_Dept.DeptName}"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">c:if</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">                            <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">c:forEach</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">table</span><span style="color: rgb(0, 0, 255);">&gt;</span></div><br /><span class="regex"><span class="normal"></span></span>其中View_User.Dept.DeptId表示USER表与DEPT表的一个关系(外键)
<br /></pre></div>你就可以看到所显示的列表了。

<p>还有如果在修改用户时，则也与上面的差不多，首先在ACTION当中加入：
<br /></p><div class="code_div"><pre><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">String ModifyUserId </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> request.getParameter(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">GroupUserId</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br /></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (ModifyUserId </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> ModifyUserId.equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)) {<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">这是出错处理</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"><br />request.setAttribute(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">UserMsg</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">User.ValidateUser</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br /></span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> mapping.findForward(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Fail</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br />}<br /><br />DynaValidatorForm UserActionForm </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (DynaValidatorForm) form;<br /><br />User user </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> UserDAO.GetUser(ModifyUserId);        <br /><br />List GetAllDept </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> UserDAO.GetAllDept();</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">取得所有部门</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"><br />request.setAttribute(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">View_Dept</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, GetAllDept);<br /><br />UserActionForm.set(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">User</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, User);</span></div><span class="punct"></span>然后页面当中显示如下(部门为LISTBOX),例子当中只显示部门
</pre></div><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">html:select </span><span style="color: rgb(255, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">="DeptAsString"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">            <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:forEach </span><span style="color: rgb(255, 0, 0);">items</span><span style="color: rgb(0, 0, 255);">="${View_Dept}"</span><span style="color: rgb(255, 0, 0);"> var</span><span style="color: rgb(0, 0, 255);">="View_Dept"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">        <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:choose</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">                        <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:when </span><span style="color: rgb(255, 0, 0);">test</span><span style="color: rgb(0, 0, 255);">="${User.Dept.DeptId==View_Dept.DeptId}"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">option    </span><span style="color: rgb(255, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">="&lt;c:out value='${View_Dept.DeptId}' /&gt;"</span><span style="color: rgb(255, 0, 0);">selected</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">    <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:out </span><span style="color: rgb(255, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">="${View_Dept.DeptName}"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);">            <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">option</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">                            <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">c:when</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">                            <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:otherwise</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">                        <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">option </span><span style="color: rgb(255, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">="&lt;c:out value='${View_Dept.DeptId}' /&gt;"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">        <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:out </span><span style="color: rgb(255, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">="${View_Dept.DeptName}"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">option</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">        <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">c:otherwise</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">                        <br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">c:choose</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">c:forEach</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">html:select</span><span style="color: rgb(0, 0, 255);">&gt;</span></div><br />可以看到HTML的SELECT有一个DeptAsString，你可以在FORM当中指定一个STRING的FORM属性。
<br />这样用户的要求就可以完成了。
<br />本次只说明方法，而代码没有经过测试。希望大家多多观注我的BLOG，下一次将臭骂ACTIONFROM不支持的DATE类型及解决方法。<img src ="http://www.blogjava.net/heweiya/aggbug/71782.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/heweiya/" target="_blank">@家军</a> 2006-09-25 16:36 <a href="http://www.blogjava.net/heweiya/archive/2006/09/25/71782.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用二维数组管理好你零乱的状态、分类和其它常用选项</title><link>http://www.blogjava.net/heweiya/archive/2006/09/05/67785.html</link><dc:creator>@家军</dc:creator><author>@家军</author><pubDate>Tue, 05 Sep 2006 05:31:00 GMT</pubDate><guid>http://www.blogjava.net/heweiya/archive/2006/09/05/67785.html</guid><wfw:comment>http://www.blogjava.net/heweiya/comments/67785.html</wfw:comment><comments>http://www.blogjava.net/heweiya/archive/2006/09/05/67785.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/heweiya/comments/commentRss/67785.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/heweiya/services/trackbacks/67785.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要:    在大家的编码过程当中，有没有遇到过这么一种情况，很多零乱的状态、分类和其它常用选项常常是定义死了。但是没有一个完整的东东来约束他，在每个模块当中使用相关的信息时，往往重新COPY一次，或者COPY过来修改一次。如果多人协作的话，务必会让代码变的零乱、不好管理等。<br>    本次主要是把一些静态的分类、状态或者其它常用选项使用二维数组管理起来。如果你是一个使用JSTL或者STRUTS做前台表现的话，你就更应该好好关注了.......&nbsp;&nbsp;<a href='http://www.blogjava.net/heweiya/archive/2006/09/05/67785.html'>阅读全文</a><img src ="http://www.blogjava.net/heweiya/aggbug/67785.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/heweiya/" target="_blank">@家军</a> 2006-09-05 13:31 <a href="http://www.blogjava.net/heweiya/archive/2006/09/05/67785.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如果失去工作会怎么办？</title><link>http://www.blogjava.net/heweiya/archive/2006/07/24/59769.html</link><dc:creator>@家军</dc:creator><author>@家军</author><pubDate>Mon, 24 Jul 2006 03:37:00 GMT</pubDate><guid>http://www.blogjava.net/heweiya/archive/2006/07/24/59769.html</guid><wfw:comment>http://www.blogjava.net/heweiya/comments/59769.html</wfw:comment><comments>http://www.blogjava.net/heweiya/archive/2006/07/24/59769.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/heweiya/comments/commentRss/59769.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/heweiya/services/trackbacks/59769.html</trackback:ping><description><![CDATA[    在工作当中，遇到了一个不明智的上级，我是刘罗锅，但是领导不一定是乾隆。设计当中的争执成为私下做对的理由，从此，我感觉到今年的财运不佳。<br />    因为工作当中的争执，而让领导失去了面子？？我在郁闷当中，为什么呀!好事反而成了坏事。<br />    领导的报复心理，让我失去了绩效，所以我感觉到财运不佳。我很想跳出这个魔鬼圈，是不是能够改善一下自己的经济收入呢？正在想离开这个公司......<br />    发现自己的软肋：UML整体设计(最好有代码生成)和XP敏捷开发。近期需要加强这两方面的学习，可以以权限设计为UML做为训练(生成代码？？)，以CRM-&gt;VtigerCRM为业务主线，做一个XP开发，不过VtigerCRM的表设计真是很糟糕，Indiea人呀。<br />    今年的公司很乱，是一个很糟糕的管理层，可能我以后离开这个公司后才感觉到领导者的“聪明才智”吧!完全在内耗当中生存。我已经被领导国边缘化，我会在灰色的区域彷徨很长的时间，或许公司另有高人吧，我已经被领导逐渐忽视，自己发光的时间也只有一年，好象知了一样。<br />    “人贵有自知之明”，如果领导没有重视，只是为了发挥自己的最低性能的话，我完全有很多的时间来学习知识，我很庆幸自己和开源代码有很大的信心，我将在以后的时间里，为开源界展示自己的能力。<br />    首先要把自己学习到的知识透明化，其次我会在开源中小型的CRM软件当中做出自己应有的贡献。<br /><img src ="http://www.blogjava.net/heweiya/aggbug/59769.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/heweiya/" target="_blank">@家军</a> 2006-07-24 11:37 <a href="http://www.blogjava.net/heweiya/archive/2006/07/24/59769.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts表单 vs JSTL表现之多条件查询示例</title><link>http://www.blogjava.net/heweiya/archive/2006/07/21/59383.html</link><dc:creator>@家军</dc:creator><author>@家军</author><pubDate>Fri, 21 Jul 2006 03:20:00 GMT</pubDate><guid>http://www.blogjava.net/heweiya/archive/2006/07/21/59383.html</guid><wfw:comment>http://www.blogjava.net/heweiya/comments/59383.html</wfw:comment><comments>http://www.blogjava.net/heweiya/archive/2006/07/21/59383.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/heweiya/comments/commentRss/59383.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/heweiya/services/trackbacks/59383.html</trackback:ping><description><![CDATA[    struts表单主要是利用actionform来取得JSP页面所有的request的，所有的Struts标签无非在取得request当中的所有INPUT,并赋值回标签值的，同理，JSTL能够在JSP表单当中轻易的表现要输出的结果。<br />    如果你是高手，你就知道这个标题有误，是的，struts表单与JSTL表现没有可比性，但是如果我们要在实现一个多条件的查询页面时，这个比较就比较有效了。<br />    我不妨比较一下利用struts表单的查询实现 和 利用JSTL做为表现而实现的查询功能有什么不同，让读者寻其方便。<br />    示例说明：<br />    用户表-USER<br />    username  用户名称<br />    loginid   登录ID<br />    sex        性别<br />    一、利用struts表单的查询实现<br />        实现步骤：<br />        创建多条件的序列化对象(java)-&gt;在struts.config当中申明actionform-&gt;Action当中实现-&gt;输出结果<br />        <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"> The value of the simple userName property. </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> java.lang.String userName;<br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"> The value of the simple loginId property. </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> java.lang.String loginId;<br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"> The value of the simple sex property. </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> java.lang.String sex;<br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * Return the value of the USER_NAME column.<br />     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"> java.lang.String<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> java.lang.String getUserName()<br />    {<br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.userName;<br />    }<br /><br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * Set the value of the USER_NAME column.<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> userName<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> setUserName(java.lang.String userName)<br />    {<br />        </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.userName </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> userName;<br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * Return the value of the LOGIN_ID column.<br />     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"> java.lang.String<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> java.lang.String getLoginId()<br />    {<br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.loginId;<br />    }<br /><br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * Set the value of the LOGIN_ID column.<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> loginId<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> setLoginId(java.lang.String loginId)<br />    {<br />        </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.loginId </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> loginId;<br />    }<br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * Return the value of the sex column.<br />     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"> java.lang.String<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> java.lang.String getSex()<br />    {<br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.sex;<br />    }<br /><br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * Set the value of the sex column.<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> loginId<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> setSex(java.lang.String sex)<br />    {<br />        </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.sex </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> sex;<br />    }</span></div><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">&lt;!-- struts_fonfig --&gt;<br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">form-bean </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="UserActionForm"</span><span style="color: rgb(255, 0, 0);"> type</span><span style="color: rgb(0, 0, 255);">="org.apache.struts.validator.DynaValidatorForm"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">form-property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="userCondition"</span><span style="color: rgb(255, 0, 0);"> type</span><span style="color: rgb(0, 0, 255);">="com.antbee.searchCondition.UserFindCondition"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);">        <br />        </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">form-bean</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>Action当中<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">DynaValidatorForm UserForm </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (DynaValidatorForm) form;<br />        UserFindCondition Condition </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (UserFindCondition) UserActionForm<br />                .get(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">userCondition</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 取得查询条件</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">List user </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> userManager.find(Condition,<br />                (iCurPageNo </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> pageCon.PAGE_SIZE, pageCon.PAGE_SIZE);</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">呵呵，加入了hibernate的分页</span></div>具体实现：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> List find(UserFindCondition Condition, </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> begin,<br />            </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> count) {<br />        StringBuffer sql </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> StringBuffer(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">from User as a where 1=1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);               <br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (Condition </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">) {<br />            makeSql(sql, shipmentFindCondition);<br />        }<br />        String fsql </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> sql.toString();<br />        Query query </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getSession().createQuery(fsql);<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (Condition </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">) {<br />            setParameter(query, Condition);<br />        }<br />        query.setFirstResult(begin);<br />        query.setMaxResults(count);<br />        List tt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> query.list();<br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> tt;<br />    }</span></div><br />--<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">    /**<br />     * 根据条件生成一个sql语句<br />     * <br />     * @author 和<br />     * @param sql<br />     *            初始的sql语句(一般为select a from A as a where 1=1)<br />     * @param condition<br />     *            查询的条件<br />     * @return<br />     * @version 1.0<br />     */<br />private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> makeSql(StringBuffer sql, UserFindCondition condition) {<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (condition.getUsername() </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">condition.getUsername().toString().equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)) {<br />            sql<br />                    .append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> and a.username like :</span><span style="color: rgb(0, 0, 0);">username</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        }<br /><br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (condition.getLoginid() </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">condition.get</span><span style="color: rgb(0, 0, 0);">Loginid(</span><span style="color: rgb(0, 0, 0);">().equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)) {<br />            sql<br />                    .append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> and a.</span><span style="color: rgb(0, 0, 0);">loginid(</span><span style="color: rgb(0, 0, 0);"> = :</span><span style="color: rgb(0, 0, 0);">loginid(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        }<br /><br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (condition.getSex() </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">condition.getSex().equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)) {<br />            sql.append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> and a.sex = :sex</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        }</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);"><br /><br />    }<br /><br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * 根据条件设置query的值<br />     * <br />     * </span><span style="color: rgb(128, 128, 128);">@author</span><span style="color: rgb(0, 128, 0);"> 和<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> query<br />     *            一个hibernate的Query对象<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> condition<br />     *            查询的条件<br />     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"><br />     * </span><span style="color: rgb(128, 128, 128);">@version</span><span style="color: rgb(0, 128, 0);"> 1.0<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> setParameter(Query query, UserFindCondition condition) {<br /><br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (condition.getUsername() </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">condition.get</span><span style="color: rgb(0, 0, 0);">Username</span><span style="color: rgb(0, 0, 0);">().equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)) {<br />            query.setString(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">username</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> condition.get</span><span style="color: rgb(0, 0, 0);">Username</span><span style="color: rgb(0, 0, 0);">()<br />                    </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        }<br /><br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (condition.getLoginid() </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">condition.get</span><span style="color: rgb(0, 0, 0);">Loginid</span><span style="color: rgb(0, 0, 0);">().equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)) {<br />            query.setString(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">loginid</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, condition.get</span><span style="color: rgb(0, 0, 0);">Loginid</span><span style="color: rgb(0, 0, 0);">());<br />        }<br /><br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (condition.getSex() </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">condition.get</span><span style="color: rgb(0, 0, 0);">Sex</span><span style="color: rgb(0, 0, 0);">().equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)) {<br />            query.setString(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">sex</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, condition.get</span><span style="color: rgb(0, 0, 0);">Sex</span><span style="color: rgb(0, 0, 0);">());<br />        }       </span><span style="color: rgb(0, 0, 0);"><br />    }</span></div><br />呵呵，笑死人了，这个方法很通用，我才在我的第二个项目当中才用到，真是可惜，当然了，使用Actionform有一个毛病就是对date类型要转换成STRING类型来处理，这是actionform的一个死穴。还有对Actionform不能够重置，只能够回来从前。不知道这群设计者怎么想的，真是由于这一点，所以我们有必要使用最原始的方法来解决问题了。使用页面当中的input，我们来拼request如何？<br />   二、利用JSTL做为表现而实现的查询功能<br />     步骤：在JSP页面布置很多的input，当然，你可以加入value了。(省略了...)<br />           创建查询条件的序列化对象(同样user.java)<br />           在action当中拼个condition了，做为查询条件，后面的处理类同第一种方式。<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">     UserSearchCondition userSearchCondition </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />     userSearchCondition </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> makeUserSearchCondition(request);</span></div><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> UserSearchCondition makeUserSearchCondition(HttpServletRequest request) </span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> Exception{<br />        </span><span style="color: rgb(0, 0, 0);">User</span><span style="color: rgb(0, 0, 0);">SearchCondition userSearchCondition </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> OrderSearchCondition();<br />        String username </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> request.getParameter(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Username</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        String loginid </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> request.getParameter(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Loginid</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        String sex </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> request.getParameter(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Sex</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);   </span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 0);"><br />                <br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">username</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">username</span><span style="color: rgb(0, 0, 0);">.trim().equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)){<br />            </span><span style="color: rgb(0, 0, 0);">username</span><span style="color: rgb(0, 0, 0);">SearchCondition.set</span><span style="color: rgb(0, 0, 0);">Username</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">username</span><span style="color: rgb(0, 0, 0);">);<br />        }<br />        <br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">loginid  </span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">loginid</span><span style="color: rgb(0, 0, 0);">.trim().equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)){<br />            userSearchCondition.set</span><span style="color: rgb(0, 0, 0);">Loginid </span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">loginid </span><span style="color: rgb(0, 0, 0);">);<br />        }<br />        <br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(sex </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">sex.trim().equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)){        <br />            userSearchCondition.setSex(</span><span style="color: rgb(0, 0, 255);">sex</span><span style="color: rgb(0, 0, 0);">);<br />        }        </span><span style="color: rgb(0, 0, 0);"><br />        <br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> userSearchCondition;<br />    }</span></div><br />     以后的方法，我就不用再做举例了吧，可以参考如上第一种方法的实现.<br />     第二种方法的好处就是：在页面上比较好控制，比如重置，又比如日期性数据等。<br />     (所有过程当中的代码没有经过测试，只是说明这种方法而已)<br /><img src ="http://www.blogjava.net/heweiya/aggbug/59383.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/heweiya/" target="_blank">@家军</a> 2006-07-21 11:20 <a href="http://www.blogjava.net/heweiya/archive/2006/07/21/59383.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>hibernate的延迟加载通用方法</title><link>http://www.blogjava.net/heweiya/archive/2006/07/21/59366.html</link><dc:creator>@家军</dc:creator><author>@家军</author><pubDate>Fri, 21 Jul 2006 02:09:00 GMT</pubDate><guid>http://www.blogjava.net/heweiya/archive/2006/07/21/59366.html</guid><wfw:comment>http://www.blogjava.net/heweiya/comments/59366.html</wfw:comment><comments>http://www.blogjava.net/heweiya/archive/2006/07/21/59366.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/heweiya/comments/commentRss/59366.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/heweiya/services/trackbacks/59366.html</trackback:ping><description><![CDATA[
		<span class="postbody">呵呵，在忙一个项目，潜水很久，现在冒个泡：<br />(本文适用在struts+spring+hibernate3上做开发的虫虫们) <br />
类名：HibernateUtil 
<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> com.antbee.j2eemodel.util;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.lang.reflect.InvocationTargetException;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.lang.reflect.Method;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.util.Collection;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.util.Iterator;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.springframework.orm.hibernate3.support.HibernateDaoSupport;<br /><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> HibernateUtil </span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);"> HibernateDaoSupport {<br /><br /></span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />* 初始化POJO类<br />* </span><span style="color: rgb(128, 128, 128);">@author</span><span style="color: rgb(0, 128, 0);"> @家军<br />* </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> object POJO对象<br />* </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> methodName 方法名称<br />* </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"><br />* </span><span style="color: rgb(128, 128, 128);">@version</span><span style="color: rgb(0, 128, 0);"> 1.0<br /></span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> initialize(Object object, String methodName) </span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {<br /><br />String[] methodArray </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> methodName.split(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">\\.</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />Method method </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />Object initializeObject </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> object;<br /><br /></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(methodArray.length </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">){<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getHibernateTemplate().lock(initializeObject, org.hibernate.LockMode.NONE);<br />method </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> object.getClass().getMethod(methodArray[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">], </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Class[] {});<br />initializeObject </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> method.invoke(initializeObject, </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Object[] {});<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getHibernateTemplate().initialize(initializeObject);<br />}</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">methodArray.length;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">){<br />method </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> initializeObject.getClass().getMethod(methodArray[i], </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Class[] {});<br />initializeObject </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> method.invoke(initializeObject, </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Object[] {});<br />}<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getHibernateTemplate().lock(initializeObject, org.hibernate.LockMode.NONE);<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getHibernateTemplate().initialize(initializeObject);<br />}<br />}<br /><br /></span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />* 初始化POJO类<br />* </span><span style="color: rgb(128, 128, 128);">@author</span><span style="color: rgb(0, 128, 0);"> @家军<br />* </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> object POJO对象<br />* </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> methodName 方法名称数组<br />* </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"><br />* </span><span style="color: rgb(128, 128, 128);">@version</span><span style="color: rgb(0, 128, 0);"> 1.0<br /></span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> initialize(Object object, String methodName[])<br /></span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> SecurityException, NoSuchMethodException,<br />IllegalArgumentException, IllegalAccessException, InvocationTargetException {<br /><br /></span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; i </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> methodName.length; i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">) {<br />String[] methodArray </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> methodName[i].split(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">\\.</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />Method method </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />Object initializeObject </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> object;<br /><br /></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(methodArray.length </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">){<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getHibernateTemplate().lock(initializeObject, org.hibernate.LockMode.NONE);<br />method </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> object.getClass().getMethod(methodArray[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">], </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Class[] {});<br />initializeObject </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> method.invoke(initializeObject, </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Object[] {});<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getHibernateTemplate().initialize(initializeObject);<br />}</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> j</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;j</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">methodArray.length;j</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">){<br />method </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> initializeObject.getClass().getMethod(methodArray[j], </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Class[] {});<br />initializeObject </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> method.invoke(initializeObject, </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Object[] {});<br />}<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getHibernateTemplate().lock(initializeObject, org.hibernate.LockMode.NONE);<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getHibernateTemplate().initialize(initializeObject);<br />}<br />}<br /><br />}<br /><br /></span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />* 初始化POJO类<br />* </span><span style="color: rgb(128, 128, 128);">@author</span><span style="color: rgb(0, 128, 0);"> @家军<br />* </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> object POJO对象<br />* </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"><br />* </span><span style="color: rgb(128, 128, 128);">@version</span><span style="color: rgb(0, 128, 0);"> 1.0<br /></span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> initialize(Object object) </span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getHibernateTemplate().lock(object, org.hibernate.LockMode.NONE);<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getHibernateTemplate().initialize(object);<br />}<br /><br /></span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />* 初始化POJO类<br />* </span><span style="color: rgb(128, 128, 128);">@author</span><span style="color: rgb(0, 128, 0);"> @家军<br />* </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> collection POJO对象集合<br />* </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> methodName 方法名称数组<br />* </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"><br />* </span><span style="color: rgb(128, 128, 128);">@version</span><span style="color: rgb(0, 128, 0);"> 1.0<br /></span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> initialize(Collection collection, String methodName[])<br /></span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> SecurityException, NoSuchMethodException,<br />IllegalArgumentException, IllegalAccessException, InvocationTargetException {<br /><br /></span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(Iterator i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">collection.iterator();i.hasNext()Wink{<br />Object object </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> i.next();<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.initialize(object,methodName);<br />}<br />}<br /><br /></span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />* 初始化POJO类<br />* </span><span style="color: rgb(128, 128, 128);">@author</span><span style="color: rgb(0, 128, 0);"> @家军<br />* </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> collection POJO对象集合<br />* </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> methodName 方法名称<br />* </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"><br />* </span><span style="color: rgb(128, 128, 128);">@version</span><span style="color: rgb(0, 128, 0);"> 1.0<br /></span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> initialize(Collection collection, String methodName)<br /></span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> SecurityException, NoSuchMethodException,<br />IllegalArgumentException, IllegalAccessException, InvocationTargetException {<br /><br /></span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(Iterator i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">collection.iterator();i.hasNext()Wink{<br />Object object </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> i.next();<br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.initialize(object,methodName);<br />}<br />}<br />} </span></div><br />
这个方法的好外是：可以不在hbm.xml的文件当中，指定为lazy=true这个模式，可以直接使用。使用方法如下：
<br />
如果你使用SPRING，则需要把hibernateUtil注入其中：
<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="hibernateUtilTarget"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="com.antbee.j2eemodel.util.HibernateUtil"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="sessionFactory"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">ref </span><span style="color: rgb(255, 0, 0);">local</span><span style="color: rgb(0, 0, 255);">="mssqlSessionFactory"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="hibernateUtil"</span><span style="color: rgb(255, 0, 0);"> parent</span><span style="color: rgb(0, 0, 255);">="BaseTransactionProxy"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="target"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">ref </span><span style="color: rgb(255, 0, 0);">local</span><span style="color: rgb(0, 0, 255);">="hibernateUtilTarget"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);">配置基础事务</span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="BaseTransactionProxy"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"</span><span style="color: rgb(255, 0, 0);"> abstract</span><span style="color: rgb(0, 0, 255);">="true"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="transactionManager"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">ref </span><span style="color: rgb(255, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">="mssqltransactionManager"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="proxyTargetClass"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">true</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="transactionAttributes"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">props</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">prop </span><span style="color: rgb(255, 0, 0);">key</span><span style="color: rgb(0, 0, 255);">="*"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">PROPAGATION_REQUIRED</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">prop</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">props</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"> </span></div><br />
使用示例：
<br />
      如果你使用STRUTS，则需要这样：
<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">List what_ur_view </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> XXXManager.find(<img src="http://www.blogjava.net/images/dot.gif" /><img src="http://www.blogjava.net/images/dot.gif" /><img src="http://www.blogjava.net/images/dot.gif" />.);</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">取得你要展示的对象<br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">如果这个对象当中有延迟加载的对象(SET)时，则需要如下加载就行</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.hibernateUtil.initialize(what_ur_view, </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">getTbShipmentSale</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">其中getTbShipmentSale是其对象(SET也可以操作) </span></div><br />
在页面显示的时候，你就可以使用JSTL如下表述：
<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:out </span><span style="color: rgb(255, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">="${what_ur_view.tbShipmentSale.goodsReceivePersonPhone}"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);">//呵呵，是不是很爽呀。 </span></div><br />
同样的方法，我们也可以对一个SET在页面进行显示，方法如下：
<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:forEach </span><span style="color: rgb(255, 0, 0);">items</span><span style="color: rgb(0, 0, 255);">="${what_ur_view.tbShipmentProductMappingSet}"</span><span style="color: rgb(255, 0, 0);"> var</span><span style="color: rgb(0, 0, 255);">="ProductMapping"</span><span style="color: rgb(255, 0, 0);"> varStatus</span><span style="color: rgb(0, 0, 255);">="status"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:out </span><span style="color: rgb(255, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">="${ProductMapping.productNum}"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:out </span><span style="color: rgb(255, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">="${ProductMapping.tbOutOfWarehouse.outOfWarehouseNum}"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">c:forEach</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />//呵呵，支持多级嵌套， </span></div><br />
在ACTION当中则需要加入<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">hibernateUtil.initialize(what_ur_view.getTbShipmentProductMappingSet(),<br /></span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> String[] { </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">getTbProduct</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">getTbOutOfWarehouse</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,<br /></span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">getTbProductConfigure</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> }); </span></div>呵，如果你要是在HIBERNATE当中使用，这个就太简单了吧。
<br /><br />
怎么样？呵呵呵，
<br />
从此，我对STRUTS的标签深恶痛绝，而对JSTL情有独钟了。
</span>
<img src ="http://www.blogjava.net/heweiya/aggbug/59366.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/heweiya/" target="_blank">@家军</a> 2006-07-21 10:09 <a href="http://www.blogjava.net/heweiya/archive/2006/07/21/59366.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>成功是一种病态的坚持!</title><link>http://www.blogjava.net/heweiya/archive/2006/07/19/59017.html</link><dc:creator>@家军</dc:creator><author>@家军</author><pubDate>Wed, 19 Jul 2006 08:35:00 GMT</pubDate><guid>http://www.blogjava.net/heweiya/archive/2006/07/19/59017.html</guid><wfw:comment>http://www.blogjava.net/heweiya/comments/59017.html</wfw:comment><comments>http://www.blogjava.net/heweiya/archive/2006/07/19/59017.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/heweiya/comments/commentRss/59017.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/heweiya/services/trackbacks/59017.html</trackback:ping><description><![CDATA[   很长的时间陷入到与同事上级的斗争当中，无聊死了，今天回来看看自己书签当中的网站，感觉到自己是小人了。我不应该留恋明争暗斗，我应该自立自强，永不停息。<br />   在年前的时候我曾经非常看好compiere的应用，想不到今天再看看国内使用的形势，长三角和珠三角的广泛应用，还有ORACLE免费数据库的推出，更加印证了我错误的做法。<br />   一个人最重要的事情就是三个字：做决定。<br />   一个人想要成功，尤其像我这样不甘愿给别人打工又有很多想法的人，除非是一种病态的坚持才能够取得成功。<br />   我很讨厌公司现行的CRM系统，简单的说一句就是：简直就是一个糊人的、丑陋的MIS系统，一点设计思想都没有，一点产品理念都没有。最重要的设计者在拼命的逃脱自己的责任，开发者在忍受莫大的痛苦，业务在每一个开发者思想里扭曲......唉，想抽出一点时间来都难。<br />   我要在以后的时候里，一则增加自己的业务能力，以compiere的应用为主；二则要增强我的技术能力，以
vTigerCRM为蓝本，做一个J2EE的产品移植。<br />   在今年年底以前，自己必须要做到对compiere的应用熟练，能够完成
vTigerCRM的J2EE实现。所以自己最重要要做的事是：时间安排，<br /><img src ="http://www.blogjava.net/heweiya/aggbug/59017.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/heweiya/" target="_blank">@家军</a> 2006-07-19 16:35 <a href="http://www.blogjava.net/heweiya/archive/2006/07/19/59017.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转摘:从一个笑话看软件开发管理</title><link>http://www.blogjava.net/heweiya/archive/2006/05/15/46226.html</link><dc:creator>@家军</dc:creator><author>@家军</author><pubDate>Mon, 15 May 2006 07:53:00 GMT</pubDate><guid>http://www.blogjava.net/heweiya/archive/2006/05/15/46226.html</guid><wfw:comment>http://www.blogjava.net/heweiya/comments/46226.html</wfw:comment><comments>http://www.blogjava.net/heweiya/archive/2006/05/15/46226.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/heweiya/comments/commentRss/46226.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/heweiya/services/trackbacks/46226.html</trackback:ping><description><![CDATA[
		<p>来自于：http://blog.csdn.net/Raptor/archive/2006/05/13/727299.aspx<br /></p>
		<p>关于软件开发的笑话有很多，下面这个是我刚在QQ群里的看到的：<br /></p>
		<blockquote>1. 程序员写出自认为没有Bug的代码。<br />2. 软件测试，发现了20个Bug。<br />3. 程序员修改了10个Bug，并告诉测试组另外10个不是Bug。<br />4. 测试组发现其中5个改动根本无法工作，同时又发现了15个新Bug。<br />5. 重复3次步骤3和步骤4。<br />6. 鉴于市场方面的压力，为了配合当初制定的过分乐观的发布时间表，产品终于上市了。<br />7. 用户发现了137个新Bug。<br />8. 已经领了项目奖金的程序员不知跑到哪里去了。<br />9. 新组建的项目组修正了差不多全部137个Bug，但又发现了456个新Bug。<br />10. 最初那个程序员从斐济给饱受拖欠工资之苦的测试组寄来了一张明信片。整个测试组集体辞职。<br />11. 公司被竞争对手恶意收购。收购时，软件的最终版本包含783个Bug。<br />12. 新CEO走马上任。公司雇了一名新程序员重写该软件。<br />13. 程序员写出自认为没有Bug的代码。</blockquote>
		<p>要我说，如果真有这样的公司，不倒闭对不起人民。</p>
		<p>这个笑话从程序员开始，到程序员结束，从头到尾都在说程序员的不是。但是我要说的是，这完全是管理者的失败，从整个过程中，看不到任何管理工作。这种管理者不但<span style="font-weight: bold;">无知无能</span>，还很<span style="font-weight: bold;">无耻</span>——将自己的失败责任推给程序员。</p>
		<p>1、程序员凭什么证明他的代码没有BUG？有Test case吗？有Code review吗？这个环节管理缺失。</p>
		<p>2、测试发现BUG有进行BUG管理吗？有跟踪吗？这个环节管理缺失。</p>
		<p>3、凭什么证明程序员已经把那10个BUG修改好了？另10个又为什么不是BUG？BUG的评价标准难道是程序员说了算？这个环节管理缺失。</p>
		<p>4、5个不能工作的BUG修改问题有没有追究责任？增加新BUG是修改过程中不可避免的事情，但是如果有有效的单元测试机制，可以大大减少这种情况。这个环节管理缺失。</p>
		<p>5、迭代是正常的，但是问题处理于发散而不是收敛发展，可见没有有效的管理调控。这个环节管理缺失。</p>
		<p>6、过于乐观的时间表和不可能达到的最后期限，都表现出管理者的无知和无能。而在这样的情况下强行推出产品，那就是无知者无畏了。</p>
		<p>7、这是对用户的不负责任，管理者要负最大的责任。</p>
		<p>8、这样的情况还能发项目奖金，只能说管理者不是一般的愚蠢。</p>
		<p>9、管理工作没有任何的改进，问题仍然处于发散迭代状态。管理工作依然没有到位。</p>
		<p>10、拖欠测试部门工资体现出管理者对质量管理工作的忽视以及对人力资源管理方面一无所知。</p>
		<p>11、送被收购者两个字：活该。送收购者两个字：瞎眼。</p>
		<p>12、可见新管理者与原管理者半斤八两，都没有认识到问题的根本所在。不过也只有这样的管理者才会作出收购这种公司的决策。</p>
		<p>13、历史的重演是必然的。</p>
		<p>一个正常的企业或是项目，其运作必须应该是循环向上进行的。而保障这种运行的工作就是管理。而管理工作的主要内容就是控制，包括控制循环的节奏——不能太快也不能太慢，控制发展的方向——只能向上不能向下，控制运作的稳定——不能大起大落或时聚时散等。</p>
		<p>而这一切，在这个例子中都看不到。</p>
		<p>在 这个笑话的例子中，一切都是以开发工作在驱动，这首先就是一个方向性错误，产品是为用户服务的，当然应该是以用户和市场作为驱动，并且结合自身的能力最终 确定工作的重点。这一错误折射出管理者对被管理的内容很不了解，只好任由比较了解的程序员摆布——事实上他们除了技术，并不会了解更多。</p>
		<p>
				<span style="font-weight: bold;">一个管理者如果对自己所管理的内容不了解，他就不可能管理得好</span>。</p>
		<p>这是一件毫无疑问的事，可是国内的软件业似乎总是不相信这一点。中国软件业中流毒最深的谎言之一就是：</p>
		<blockquote>管理者只要懂管理就可以，不需要懂技术。</blockquote>
		<p>其实这不过是那些无知无能无耻的管理者为了骗钱而编出来的，相信这句话的人必将付出金钱的代价。</p>
		<p>其 次是质量管理。基本的质量管理常识告诉我们，每次循环结束前，最重的工作就是总结改进。只有这样才能保证循环运作是向上发展，而不是失去控制地向下发展。 也只有有效的质量管理，才能保证迭代过程是收敛发展，并最终达到目标。但在这个例子中，这个部分显然是缺失的——其中虽然有测试部门，但是他们的作用仅仅 是质量管理中的质量检测环节，管理部分还是缺失的。</p>
		<p>然后是人力资源管理。软件开发是一项劳动密集型的工作，虽然这是脑力劳动，但同样意味着人在因素在其中占有决定性的地位。而例子中未改完BUG的程 序员拿到项目奖金，而同样辛苦工作的测试人员却被拖欠薪资，除了表现出管理者对他们的工作内容的不了解，以及对质量管理工作的不重视以外，还表现出管理者 完全不会管人，这是一种谋杀团队的行为——谋杀一个团队远比建设要容易得多。</p>
		<p>最后，这个失败的管理者把他的经历编成这个笑话，让大家看到他被程序员们害得多惨，把程序员妖魔化为一群骗子。但只要稍懂管理的人简单分析一下就可以看出来，只不过是这个人的无知和无能造成了他现在的结果，而把责任推给别人的行为更是表现出他的无耻。</p>
		<p>作为身居高位的管理者，如果连应该承担的责任都要推卸，他们还能胜任什么事情呢？<br /></p>
<img src ="http://www.blogjava.net/heweiya/aggbug/46226.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/heweiya/" target="_blank">@家军</a> 2006-05-15 15:53 <a href="http://www.blogjava.net/heweiya/archive/2006/05/15/46226.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>