<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>木乃y &#187; CS</title>
	<atom:link href="http://vzless.info/category/cmputer-science/feed/" rel="self" type="application/rss+xml" />
	<link>http://vzless.info</link>
	<description>simple way of life,freedom from care</description>
	<lastBuildDate>Mon, 01 Feb 2010 05:40:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>sql积累1.日期</title>
		<link>http://vzless.info/2009/12/06/sql-date/</link>
		<comments>http://vzless.info/2009/12/06/sql-date/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 14:14:14 +0000</pubDate>
		<dc:creator>木乃y</dc:creator>
				<category><![CDATA[CS]]></category>

		<guid isPermaLink="false">http://vzless.info/?p=445</guid>
		<description><![CDATA[报表工具、框架用的多了，导致自己写复杂sql的地方不多，以至于现在写个sql感觉都困难，开始一点点积累使用频繁的一些条件，知道一点积累一点，
Oracle
日期条件：
&#8211;zh_cn系统日期格式
select * from emp where hiredate &#62; &#8216;12-5月 -87&#8242;;
&#8211;或者
select * from emp where hiredate &#62; to_date(&#8216;1981/11/14&#8242;,&#8217;yyyy/mm/dd&#8217;);
按阶段统计
&#8211;每月的每周统计
SELECT   to_char(createtime,&#8217;yyyymm&#8217;)   年月,   &#8216;第&#8217;   &#124;&#124;   to_char(createtime,&#8217;w')   &#124;&#124;   &#8216;周&#8217;   周,   COUNT(*)  数量
FROM   test   GROUP   BY   to_char(createtime,&#8217;yyyymm&#8217;),to_char(createtime,&#8217;w');
SELECT   to_char(createtime,&#8217;yyyymm&#8217;)   年月  ,  COUNT(*)   发贴数
FROM   test0123   GROUP [...]]]></description>
			<content:encoded><![CDATA[<p>报表工具、框架用的多了，导致自己写复杂sql的地方不多，以至于现在写个sql感觉都困难，开始一点点积累使用频繁的一些条件，知道一点积累一点，</p>
<p>Oracle</p>
<p>日期条件：</p>
<p>&#8211;zh_cn系统日期格式<br />
select * from emp where hiredate &gt; &#8216;12-5月 -87&#8242;;<br />
&#8211;或者<br />
select * from emp where hiredate &gt; to_date(&#8216;1981/11/14&#8242;,&#8217;yyyy/mm/dd&#8217;);</p>
<p>按阶段统计</p>
<p>&#8211;每月的每周统计</p>
<p>SELECT   to_char(createtime,&#8217;yyyymm&#8217;)   年月,   &#8216;第&#8217;   ||   to_char(createtime,&#8217;w')   ||   &#8216;周&#8217;   周,   COUNT(*)  数量</p>
<p>FROM   test   GROUP   BY   to_char(createtime,&#8217;yyyymm&#8217;),to_char(createtime,&#8217;w');</p>
<div id="_mcePaste" style="position: absolute; overflow-x: hidden; overflow-y: hidden; width: 1px; height: 1px; top: 0px; left: -10000px;">SELECT   to_char(createtime,&#8217;yyyymm&#8217;)   年月  ,  COUNT(*)   发贴数</div>
<div id="_mcePaste" style="position: absolute; overflow-x: hidden; overflow-y: hidden; width: 1px; height: 1px; top: 0px; left: -10000px;">FROM   test0123   GROUP   BY   to_char(createtime,&#8217;yyyymm&#8217;);</div>
<p>&#8211;按月份分组统计</p>
<p>SELECT   to_char(createtime,&#8217;yyyymm&#8217;)   年月  ,  COUNT(*)   count</p>
<p>FROM   test  GROUP   BY   to_char(createtime,&#8217;yyyymm&#8217;);</p>
]]></content:encoded>
			<wfw:commentRss>http://vzless.info/2009/12/06/sql-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle数据库常用简单的命令</title>
		<link>http://vzless.info/2009/11/16/oracle-bas/</link>
		<comments>http://vzless.info/2009/11/16/oracle-bas/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 18:24:29 +0000</pubDate>
		<dc:creator>木乃y</dc:creator>
				<category><![CDATA[CS]]></category>

		<guid isPermaLink="false">http://vzless.info/?p=419</guid>
		<description><![CDATA[数据库的维护很少用，一个项目也就初期建库时候用一下简单的算是“DBA”的命令，以下是自己日常总结的常用，没一丁点技术含量。
DBA部分：
&#8211;创建一个新的【表空间】：
 create tablespace hkrsoft datafile &#8216;E:\oracle\product\10.1.0\oradata\orcl\hkrsoft.dbf&#8217; size 50M;
&#8211;删除
 drop tablespace test;
&#8211;查看表空间信息：
 select * from dba_tablespaces;
&#8211;或者command：
 desc dba_tablespaces;
 tips：
 删除表空间文件引起：数据库未打开
 alter database datafile &#8216;E:\oracle\product\10.1.0\oradata\nhu\xianyou.dbf&#8217; offline drop;
 alter database open;
&#8211;设置数据文件自动增长 
ALTER   TABLESPACE   tablespaceName   DATAFILE   &#8216;datafileName.dbf&#8217;   AUTOEXTEND   ON;  
&#8211;设置数据文件容量无限 
ALTER   TABLESPACE   tablespaceName   DATAFILE   &#8216;datafileName.dbf&#8217;   MAXSIZE   UNLIMITED; 
 
创建【用户】到某一个表空间：
 create user 用户名 identified by 口令 [externally]
 [default tablesapce 表空间名]
 [temporary tablespace 临时表空间名]
 [quota 整数 K&#124;M&#124;unlimited on 表空间名]
&#8211;示例：
 create user hkr identified by hkr default tablespace hkrsoft quota [...]]]></description>
			<content:encoded><![CDATA[<p>数据库的维护很少用，一个项目也就初期建库时候用一下简单的算是“DBA”的命令，以下是自己日常总结的常用，没一丁点技术含量。</p>
<p>DBA部分：<br />
&#8211;创建一个新的【表空间】：<br />
 create tablespace hkrsoft datafile &#8216;E:\oracle\product\10.1.0\oradata\orcl\hkrsoft.dbf&#8217; size 50M;<br />
&#8211;删除<br />
 drop tablespace test;<br />
&#8211;查看表空间信息：<br />
 select * from dba_tablespaces;<br />
&#8211;或者command：<br />
 desc dba_tablespaces;<br />
 tips：<br />
 删除表空间文件引起：数据库未打开<br />
 alter database datafile &#8216;E:\oracle\product\10.1.0\oradata\nhu\xianyou.dbf&#8217; offline drop;<br />
 alter database open;<br />
&#8211;设置数据文件自动增长 <br />
ALTER   TABLESPACE   tablespaceName   DATAFILE   &#8216;datafileName.dbf&#8217;   AUTOEXTEND   ON;  <br />
&#8211;设置数据文件容量无限 <br />
ALTER   TABLESPACE   tablespaceName   DATAFILE   &#8216;datafileName.dbf&#8217;   MAXSIZE   UNLIMITED; <br />
 <br />
创建【用户】到某一个表空间：<br />
 create user 用户名 identified by 口令 [externally]<br />
 [default tablesapce 表空间名]<br />
 [temporary tablespace 临时表空间名]<br />
 [quota 整数 K|M|unlimited on 表空间名]<br />
&#8211;示例：<br />
 create user hkr identified by hkr default tablespace hkrsoft quota 30m on hkrsoft;<br />
&#8211;查看用户名称<br />
 select   username   from     all_users;  <br />
&#8211;删除用户<br />
 drop user XXXX cascade;</p>
<p>&#8211;查看当前用户的所拥有的表、字段、键约束<br />
 Select * From user_all_tables<br />
 Select * From user_tab_cols<br />
 Select * From all_constraints<br />
 <br />
&#8211;导入导出<br />
自己常用：<br />
导出某个用户的表：<br />
exp system/manager@TEST file=d:daochu.dmp owner=(system,sys)；<br />
导入全库方式（Full方式），数据库中的所有对象导出，并记录日志到log，STATISTICS 分析对象 (ESTIMATE)：涉及版本或字符集问题忽略，表示不导出分析数据 。<br />
imp xsj@xsj file=xsj-0821.dmp full=y statistics=none log=20091101.log ignore=y</p>
<p>改变表拥有者<br />
先建立import9.par,<br />
  然后，使用时命令如下：imp parfile=/filepath/import9.par<br />
  例 import9.par 内容如下：<br />
        FROMUSER=TGPMS       <br />
        TOUSER=TGPMS2     （注：把表的拥有者由FROMUSER改为TOUSER，FROMUSER和TOUSER的用户可以不同）          <br />
        ROWS=Y<br />
        INDEXES=Y<br />
        GRANTS=Y<br />
        CONSTRAINTS=Y<br />
        BUFFER=409600<br />
        file==/backup/ctgpc_20030623.dmp<br />
        log==/backup/import_20030623.log</p>
<p> </p>
<p>【下面这一段网上直接摘录别人总结的。】<br />
<span id="more-419"></span>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
下面介绍的是导入导出的实例。<br />
数据导出：<br />
 1 将数据库TEST完全导出,用户名system 密码manager 导出到D:daochu.dmp中<br />
   exp system/manager@TEST file=d:daochu.dmp full=y<br />
 2 将数据库中system用户与sys用户的表导出<br />
   exp system/manager@TEST file=d:daochu.dmp owner=(system,sys)<br />
 3 将数据库中的表inner_notify、notify_staff_relat导出<br />
    exp aichannel/aichannel@TESTDB2 file= d:datanewsmgnt.dmp tables=(inner_notify,notify_staff_relat)</p>
<p> 4 将数据库中的表table1中的字段filed1以&#8221;00&#8243;打头的数据导出<br />
   exp system/manager@TEST file=d:daochu.dmp tables=(table1) query=&#8221; where filed1 like &#8216;00%&#8217;&#8221;<br />
 <br />
  上面是常用的导出，对于压缩，既用winzip把dmp文件可以很好的压缩。<br />
  也可以在上面命令后面 加上 compress=y 来实现。<br />
数据的导入<br />
 1 将D:daochu.dmp 中的数据导入 TEST数据库中。<br />
   imp system/manager@TEST  file=d:daochu.dmp<br />
   imp aichannel/aichannel@HUST full=y  file=file= d:datanewsmgnt.dmp ignore=y<br />
   上面可能有点问题，因为有的表已经存在，然后它就报错，对该表就不进行导入。<br />
   在后面加上 ignore=y 就可以了。<br />
 2 将d:daochu.dmp中的表table1 导入<br />
 imp system/manager@TEST  file=d:daochu.dmp  tables=(table1)<br />
 <br />
 基本上上面的导入导出够用了。不少情况要先是将表彻底删除，然后导入。<br />
 <br />
注意：<br />
 操作者要有足够的权限，权限不够它会提示。<br />
 数据库时可以连上的。可以用tnsping TEST 来获得数据库TEST能否连上。</p>
<p>附录一：<br />
 给用户增加导入数据权限的操作<br />
 第一,启动sql*puls<br />
 第二，以system/manager登陆<br />
 第三，create user 用户名 IDENTIFIED BY 密码 （如果已经创建过用户，这步可以省略）<br />
 第四，GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,<br />
   DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,<br />
      DBA,CONNECT,RESOURCE,CREATE SESSION  TO 用户名字<br />
 第五, 运行-cmd-进入dmp文件所在的目录,<br />
      imp userid=system/manager full=y file=*.dmp<br />
      或者 imp userid=system/manager full=y file=filename.dmp</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
]]></content:encoded>
			<wfw:commentRss>http://vzless.info/2009/11/16/oracle-bas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>华夏银行信用卡中心IT笔试题</title>
		<link>http://vzless.info/2009/11/13/hxyh-bishi/</link>
		<comments>http://vzless.info/2009/11/13/hxyh-bishi/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 17:25:46 +0000</pubDate>
		<dc:creator>木乃y</dc:creator>
				<category><![CDATA[CS]]></category>
		<category><![CDATA[生活]]></category>
		<category><![CDATA[IT项目经理助理]]></category>
		<category><![CDATA[华夏银行信用卡中心笔试]]></category>

		<guid isPermaLink="false">http://vzless.info/?p=413</guid>
		<description><![CDATA[数学、金融、管理、IT&#8230;..，平时写sql语句少都忘了，吃亏了，估计没戏了，拿来共享
1、有两根不均匀分布的香，每根香烧完的时间是一个小时，你能用什么方法来确定一段45分钟的时间？
2、5人在一圆桌吃饭，排列方法有多少？
3、2001年1月1日是周四，2009年1月1日是多少？
4、6只猫6分钟捉6只老鼠，十分钟10只老鼠几只猫？
5、1000以内连续正整数和为1000组数
linux基本操作若干
数据库若干：
存储过程和函数区别
甲100-91乙90-81丙80-71丁70-60等四类学生成绩，求各类比例
&#62;信用卡知识
&#62;银行知识
&#62;VISA白金俱乐部成立会议，起草email邮件会议通知
&#62;劝说老板上马项目，且预算有10增到-50万
&#62;项目集成生命周期及成果
&#62;有一产品开发临近尾声，试运营期间用户反映良好，突然政府政策变化，某些功能受政府政策影响需要变化，此时如何同客户协调？你会如何做
]]></description>
			<content:encoded><![CDATA[<p>数学、金融、管理、IT&#8230;..，平时写sql语句少都忘了，吃亏了，估计没戏了，拿来共享</p>
<p>1、有两根不均匀分布的香，每根香烧完的时间是一个小时，你能用什么方法来确定一段45分钟的时间？</p>
<p>2、5人在一圆桌吃饭，排列方法有多少？</p>
<p>3、2001年1月1日是周四，2009年1月1日是多少？</p>
<p>4、6只猫6分钟捉6只老鼠，十分钟10只老鼠几只猫？</p>
<p>5、1000以内连续正整数和为1000组数</p>
<p>linux基本操作若干</p>
<p>数据库若干：</p>
<p>存储过程和函数区别</p>
<p>甲100-91乙90-81丙80-71丁70-60等四类学生成绩，求各类比例</p>
<p>&gt;信用卡知识</p>
<p>&gt;银行知识</p>
<p>&gt;VISA白金俱乐部成立会议，起草email邮件会议通知</p>
<p>&gt;劝说老板上马项目，且预算有10增到-50万</p>
<p>&gt;项目集成生命周期及成果</p>
<p>&gt;有一产品开发临近尾声，试运营期间用户反映良好，突然政府政策变化，某些功能受政府政策影响需要变化，此时如何同客户协调？你会如何做</p>
]]></content:encoded>
			<wfw:commentRss>http://vzless.info/2009/11/13/hxyh-bishi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>有道难题+答案</title>
		<link>http://vzless.info/2009/05/06/youdao-nanti-mi/</link>
		<comments>http://vzless.info/2009/05/06/youdao-nanti-mi/#comments</comments>
		<pubDate>Wed, 06 May 2009 13:48:28 +0000</pubDate>
		<dc:creator>木乃y</dc:creator>
				<category><![CDATA[CS]]></category>
		<category><![CDATA[生活]]></category>
		<category><![CDATA[有道难题]]></category>
		<category><![CDATA[有道难题答案]]></category>

		<guid isPermaLink="false">http://vzless.info/?p=297</guid>
		<description><![CDATA[twitter上面matrix67推了个连接，http://www.youdao.com/nanti/mi/
有道难题，我费了将近一个小时才猜出来3个
第一题：
谷歌、有道、搜狗、雅虎都有的两个同样人物？
写出来，google，youdao，sougou，yahoo：两个O
第二题

一个图片
左右镜像翻转一下：看到：pun is bomb
所以答案是bomb 炸弹
第三题

同样是一个图片，同样是左右镜像，看到四个数字，搜一下，原来是五岳的海拔。炸弹竟然在嵩山哈哈
第四题不会了，ascii？正则？乱猜一同，无果 搜一下，原来大牛已经破解出来答案(有道快贴里面有人给出答案的位置，不过是phprpc加密的http://www.youdao.com/nanti/mi/server.php)

phprpc_functions=&#34;YTo1OntpOjA7czoxMjoiZ2V0cXVlc3Rpb25zIjtpOjE7czo4OiJnZXRiaWxscyI7aToyO3M6MTI6ImdldHRvdGFsbGlzdCI7aTozO3M6OToicG9zdHNjb3JlIjtpOjQ7czoxMToicG9zdGNvbnRhY3QiO30=&#34;;

google博客搜索，牛人在此，dump破解之
以下内容引用自
est&#8217;s blog
http://initiative.yo2.cn/archives/639837：
So, here&#8217;s the answers:
有道这个JR居然用PHPRPC把所有答案加密了。哼哼。任何加密都挡不住内存dump大法。


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34; ?&#62;
&#60;data radius=&#34;220&#34; a=&#34;320&#34; b=&#34;170&#34; skey=&#34;youdao&#34;&#62;
&#60;question src=&#34;questions/q1oioqzvveoalz.fa.swf&#34; answer=&#34;o&#34; lowcase=&#34;true&#34; visible=&#34;true&#34;&#62;一样的人物&#60;/question&#62;
&#60;question src=&#34;questions/q80afzfdqrezxc0-rwq.f0.swf&#34; answer=&#34;bomb&#34; lowcase=&#34;true&#34; visible=&#34;true&#34;&#62;湖边的回忆&#60;/question&#62;
&#60;question src=&#34;questions/q4098azvhlaql.f-fq53.swf&#34; answer=&#34;0441&#34; visible=&#34;true&#34;&#62;危险之地&#60;/question&#62;
&#60;question src=&#34;questions/q3zlllweafl342laozl.swf&#34; answer=&#34;@($&#34; visible=&#34;true&#34; locked=&#34;true&#34;&#62;火星文&#60;/question&#62;
&#60;question src=&#34;questions/q5zpaqa.eop2-f-qe4.swf&#34; answer=&#34;也可能&#34; visible=&#34;true&#34; locked=&#34;true&#34;&#62;博客中的线索&#60;/question&#62;
&#60;question src=&#34;questions/q6pkltix.04.-af.swf&#34; answer=&#34;本机地址&#34; visible=&#34;true&#34; locked=&#34;true&#34;&#62;IT码农的留言&#60;/question&#62;
&#60;question src=&#34;questions/q70a9fdalqrexc65o.vz.swf&#34; answer=&#34;search engine&#34; lowcase=&#34;true&#34; visible=&#34;true&#34; locked=&#34;true&#34;&#62;曲径通幽&#60;/question&#62;
&#60;question src=&#34;questions/q909qalzxovaltazt-fq.fq.swf&#34; answer=&#34;为&#34; visible=&#34;true&#34; locked=&#34;true&#34;&#62;手机词典的帮助&#60;/question&#62;
&#60;question src=&#34;questions/q10090zvalzp-f.4.swf&#34; answer=&#34;3624087915&#34; visible=&#34;true&#34; locked=&#34;true&#34;&#62;古诗中的数字&#60;/question&#62;
&#60;question src=&#34;questions/q2098alzraz.5.ao.swf&#34; answer=&#34;12355331&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>twitter上面matrix67推了个连接，http://www.youdao.com/nanti/mi/</p>
<p>有道难题，我费了将近一个小时才猜出来3个</p>
<p>第一题：</p>
<p>谷歌、有道、搜狗、雅虎都有的两个同样人物？</p>
<p>写出来，google，youdao，sougou，yahoo：两个O</p>
<p>第二题</p>
<p><a href="http://vzless.info/wp-content/uploads/2009/05/2.png"><img title="2" src="http://vzless.info/wp-content/uploads/2009/05/2.png" alt="" width="385" height="248" /></a></p>
<p>一个图片</p>
<p>左右镜像翻转一下：看到：pun is bomb</p>
<p>所以答案是bomb 炸弹</p>
<p>第三题</p>
<p><a href="http://vzless.info/wp-content/uploads/2009/05/1-1.png"><img class="alignnone size-full wp-image-302" title="1-1" src="http://vzless.info/wp-content/uploads/2009/05/1-1.png" alt="" width="500" height="253" /></a></p>
<p>同样是一个图片，同样是左右镜像，看到四个数字，搜一下，原来是五岳的海拔。炸弹竟然在嵩山哈哈</p>
<p>第四题不会了，ascii？正则？乱猜一同，无果 搜一下，原来大牛已经破解出来答案(有道快贴里面有人给出答案的位置，不过是phprpc加密的<a href="http://www.youdao.com/nanti/mi/server.php">http://www.youdao.com/nanti/mi/server.php</a>)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">phprpc_functions<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;YTo1OntpOjA7czoxMjoiZ2V0cXVlc3Rpb25zIjtpOjE7czo4OiJnZXRiaWxscyI7aToyO3M6MTI6ImdldHRvdGFsbGlzdCI7aTozO3M6OToicG9zdHNjb3JlIjtpOjQ7czoxMToicG9zdGNvbnRhY3QiO30=&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<blockquote><p>google博客搜索，牛人在此，dump破解之<br />
以下内容引用自</p>
<h3><a href="http://initiative.yo2.cn/">est&#8217;s blog</a></h3>
<p><a href="http://initiative.yo2.cn/archives/639837">http://initiative.yo2.cn/archives/639837</a>：</p>
<p>So, here&#8217;s the answers:<br />
有道这个JR居然用PHPRPC把所有答案加密了。哼哼。任何加密都挡不住内存dump大法。<br />
<span id="more-297"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;data</span> <span style="color: #000066;">radius</span>=<span style="color: #ff0000;">&quot;220&quot;</span> <span style="color: #000066;">a</span>=<span style="color: #ff0000;">&quot;320&quot;</span> <span style="color: #000066;">b</span>=<span style="color: #ff0000;">&quot;170&quot;</span> <span style="color: #000066;">skey</span>=<span style="color: #ff0000;">&quot;youdao&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q1oioqzvveoalz.fa.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;o&quot;</span> <span style="color: #000066;">lowcase</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>一样的人物<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q80afzfdqrezxc0-rwq.f0.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;bomb&quot;</span> <span style="color: #000066;">lowcase</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>湖边的回忆<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q4098azvhlaql.f-fq53.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;0441&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>危险之地<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q3zlllweafl342laozl.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;@($&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>火星文<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q5zpaqa.eop2-f-qe4.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;也可能&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>博客中的线索<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q6pkltix.04.-af.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;本机地址&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>IT码农的留言<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q70a9fdalqrexc65o.vz.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;search engine&quot;</span> <span style="color: #000066;">lowcase</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>曲径通幽<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q909qalzxovaltazt-fq.fq.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;为&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>手机词典的帮助<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q10090zvalzp-f.4.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;3624087915&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>古诗中的数字<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q2098alzraz.5.ao.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;12355331&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>彩铃包月<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q1109zgflqre0f-aw.w2.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;2月18日||二月十八日&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>和智玲的聊天<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q120z0fda2r.z0f-a2.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;cctv&quot;</span> <span style="color: #000066;">lowcase</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>黑客是怎样炼成的<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q13-zf0w2rzlf0.f43.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;圆周率||祖冲之&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">open</span>=<span style="color: #ff0000;">&quot;15&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Morse的登录<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q1409falz-fa.2aof.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;0731-5310163&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>错误的号码<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q160z-af.4er0zafwe.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;LOVE&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>数学之美<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;question</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;questions/q170z.gzzf-32zflgpqert.swf&quot;</span> <span style="color: #000066;">answer</span>=<span style="color: #ff0000;">&quot;ONLMK&quot;</span> <span style="color: #000066;">lowcase</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">visible</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>残破的画卷<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/question<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/data<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://vzless.info/2009/05/06/youdao-nanti-mi/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>WebService by axis</title>
		<link>http://vzless.info/2009/04/12/hkr-03-webservice/</link>
		<comments>http://vzless.info/2009/04/12/hkr-03-webservice/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 17:31:03 +0000</pubDate>
		<dc:creator>木乃y</dc:creator>
				<category><![CDATA[CS]]></category>
		<category><![CDATA[WebService]]></category>
		<category><![CDATA[对象序列化]]></category>
		<category><![CDATA[自定义异常]]></category>

		<guid isPermaLink="false">http://vzless.info/?p=278</guid>
		<description><![CDATA[前两个一个poi读写excel文件,定位错误数据；一个java+js编写树状结构。感觉自己是出色完成了任务，嘿嘿。
实习任务三：做一个简单的Webservice登录webapp，资料自己找，时间3天,虽说举步维艰，一步一个bug，但实际用时，一天 嘿嘿
总结一下，积累。下周要学普元的EOS，感觉怪怪的一个东东，863?好像骂的不少，不过，还是积累&#8211;但行好事莫问前程，嗨，真没出息
1、默认大家对soa有所了解：why soa，soa怎么做的？
2、即时发布Helloworld的程序到处都是，只是注意：即时发布不支持带包的java程序，所以很少用
另外activation.jar，mail.jar在myeclipse的j2ee的lib里面有的
3、说一下定制发布 主要参考：http://blog.csdn.net/chnic/archive/2008/03/13/2179760.aspx
我的步骤：
1、后台数据库准备一条简单的数据：Username=&#8221;Admin&#8221;，password=&#8221;admin&#8221;
2、编写自己要提供给别人的业务逻辑(服务端，你要清楚你要干什么)

package info.vzless.ws;
&#160;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
&#160;
public class Login &#123;
&#160;
	public UserBean login&#40;String userName,String password&#41; throws UserNotFoundException, PswNotCorrectException&#123;
		UserBean user = null;
&#160;
		user = findUser&#40;userName&#41;;
		if&#40;user==null&#41;&#123;
			throw new UserNotFoundException&#40;&#34;用户未找到!&#34;&#41;;
		&#125;
		if&#40;!password.equals&#40;user.getPassWord&#40;&#41;&#41;&#41;&#123;
			throw new PswNotCorrectException&#40;&#34;密码错误!&#34;&#41;;
		&#125;
		return user;
	&#125;
	public UserBean findUser&#40;String userName&#41;&#123;
		UserBean user = null;
&#160;
		String sql = &#34;select * from Users where userName=?&#34;;
		Connection conn = DBUtil.getConnecton&#40;&#41;;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
&#160;
		try &#123;
			pstmt = conn.prepareStatement&#40;sql&#41;;
			pstmt.setString&#40;1, [...]]]></description>
			<content:encoded><![CDATA[<p>前两个一个poi读写excel文件,定位错误数据；一个java+js编写树状结构。感觉自己是出色完成了任务，嘿嘿。</p>
<p>实习任务三：做一个简单的Webservice登录webapp，资料自己找，时间3天,虽说举步维艰，一步一个bug，但实际用时，一天 嘿嘿<br />
总结一下，积累。下周要学普元的EOS，感觉怪怪的一个东东，863?好像骂的不少，不过，还是积累&#8211;但行好事莫问前程，嗨，真没出息</p>
<p>1、默认大家对soa有所了解：why soa，soa怎么做的？</p>
<p>2、即时发布Helloworld的程序到处都是，只是注意：即时发布不支持带包的java程序，所以很少用<br />
另外activation.jar，mail.jar在myeclipse的j2ee的lib里面有的<br />
3、说一下定制发布 主要参考：<a href="http://blog.csdn.net/chnic/archive/2008/03/13/2179760.aspx">http://blog.csdn.net/chnic/archive/2008/03/13/2179760.aspx</a></p>
<p>我的步骤：<br />
1、后台数据库准备一条简单的数据：Username=&#8221;Admin&#8221;，password=&#8221;admin&#8221;<br />
2、编写自己要提供给别人的业务逻辑(服务端，你要清楚你要干什么)<span id="more-278"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">info.vzless.ws</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.Connection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.PreparedStatement</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.ResultSet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.SQLException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Login <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> UserBean login<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userName,<span style="color: #003399;">String</span> password<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> UserNotFoundException, PswNotCorrectException<span style="color: #009900;">&#123;</span>
		UserBean user <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
		user <span style="color: #339933;">=</span> findUser<span style="color: #009900;">&#40;</span>userName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>user<span style="color: #339933;">==</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> UserNotFoundException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;用户未找到!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>password.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>user.<span style="color: #006633;">getPassWord</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> PswNotCorrectException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;密码错误!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> user<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> UserBean findUser<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		UserBean user <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">String</span> sql <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from Users where userName=?&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Connection</span> conn <span style="color: #339933;">=</span> DBUtil.<span style="color: #006633;">getConnecton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">PreparedStatement</span> pstmt <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">ResultSet</span> rs <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			pstmt <span style="color: #339933;">=</span> conn.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">&#40;</span>sql<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, userName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			rs <span style="color: #339933;">=</span> pstmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				user <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UserBean<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				user.<span style="color: #006633;">setUserName</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;userName&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				user.<span style="color: #006633;">setPassWord</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;psw&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">SQLException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;findeUser(String userName,String password)错误&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
			DBUtil.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span>rs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			DBUtil.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span>pstmt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			DBUtil.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span>conn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> user<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>3、在web-inf下面编写deploy.wsdd文件，主要就是告诉别人你开放哪些类的哪些方法供别人使用,以及自定义javabean的远程传输，这里是要牵扯到对象的序列化的。还有remoteException的定义(就这几点吧)<br />
&#8211;贴代码</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;deployment</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://xml.apache.org/axis/wsdd/&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:java</span>=<span style="color: #ff0000;">&quot;http://xml.apache.org/axis/wsdd/providers/java&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Login&quot;</span> <span style="color: #000066;">provider</span>=<span style="color: #ff0000;">&quot;java:RPC&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;className&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;info.vzless.ws.Login&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;allowedMethods&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;login&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;scope&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Session&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;operation</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;login&quot;</span> <span style="color: #000066;">qname</span>=<span style="color: #ff0000;">&quot;operNS:login&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">xmlns:operNS</span>=<span style="color: #ff0000;">&quot;getSingleUser&quot;</span> <span style="color: #000066;">returnQName</span>=<span style="color: #ff0000;">&quot;getUserReturn&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">returnType</span>=<span style="color: #ff0000;">&quot;rtns:User&quot;</span> <span style="color: #000066;">xmlns:rtns</span>=<span style="color: #ff0000;">&quot;http://vzless.info&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;userName&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;tns:String&quot;</span></span>
<span style="color: #009900;">				<span style="color: #000066;">xmlns:tns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;passWord&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;tns:String&quot;</span></span>
<span style="color: #009900;">				<span style="color: #000066;">xmlns:tns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fault</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PswNotCorrectException&quot;</span> <span style="color: #000066;">qname</span>=<span style="color: #ff0000;">&quot;fns:fault&quot;</span></span>
<span style="color: #009900;">				<span style="color: #000066;">xmlns:fns</span>=<span style="color: #ff0000;">&quot;http://vzless.info&quot;</span></span>
<span style="color: #009900;">				<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;info.vzless.ws.PswNotCorrectException&quot;</span></span>
<span style="color: #009900;">				<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;tns:PswNotCorrectException&quot;</span> <span style="color: #000066;">xmlns:tns</span>=<span style="color: #ff0000;">&quot;http://vzless.info&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fault</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;UserNotFoundException&quot;</span> <span style="color: #000066;">qname</span>=<span style="color: #ff0000;">&quot;fns:fault&quot;</span></span>
<span style="color: #009900;">				<span style="color: #000066;">xmlns:fns</span>=<span style="color: #ff0000;">&quot;http://vzless.info&quot;</span></span>
<span style="color: #009900;">				<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;info.vzless.ws.UserNotFoundException&quot;</span></span>
<span style="color: #009900;">				<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;tns:UserNotFoundException&quot;</span> <span style="color: #000066;">xmlns:tns</span>=<span style="color: #ff0000;">&quot;http://vzless.info&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/operation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;typeMapping</span> <span style="color: #000066;">qname</span>=<span style="color: #ff0000;">&quot;myns:User&quot;</span> <span style="color: #000066;">xmlns:myns</span>=<span style="color: #ff0000;">&quot;urn:CustomerBean&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;java:info.vzless.ws.UserBean&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">serializer</span>=<span style="color: #ff0000;">&quot;org.apache.axis.encoding.ser.BeanSerializerFactory&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">deserializer</span>=<span style="color: #ff0000;">&quot;org.apache.axis.encoding.ser.BeanDeserializerFactory&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">encodingStyle</span>=<span style="color: #ff0000;">&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;typeMapping</span> <span style="color: #000066;">qname</span>=<span style="color: #ff0000;">&quot;myns:PswNotCorrectException&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">xmlns:myns</span>=<span style="color: #ff0000;">&quot;urn:CustomerFault&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;java:info.vzless.ws.PswNotCorrectException&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">serializer</span>=<span style="color: #ff0000;">&quot;org.apache.axis.encoding.ser.BeanSerializerFactory&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">deserializer</span>=<span style="color: #ff0000;">&quot;org.apache.axis.encoding.ser.BeanDeserializerFactory&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">encodingStyle</span>=<span style="color: #ff0000;">&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;typeMapping</span> <span style="color: #000066;">qname</span>=<span style="color: #ff0000;">&quot;myns:UserNotFoundException&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">xmlns:myns</span>=<span style="color: #ff0000;">&quot;urn:CustomerFault&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;java:info.vzless.ws.UserNotFoundException&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">serializer</span>=<span style="color: #ff0000;">&quot;org.apache.axis.encoding.ser.BeanSerializerFactory&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">deserializer</span>=<span style="color: #ff0000;">&quot;org.apache.axis.encoding.ser.BeanDeserializerFactory&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">encodingStyle</span>=<span style="color: #ff0000;">&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/deployment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>其中 deployment xmlns=&#8221;<a href="http://xml.apache.org/axis/wsdd/">http://xml.apache.org/axis/wsdd/</a>&#8221; 记得双引号，一定要规范，上面那个连接中作者没加，部署wsdd时候会提示缺少quote。<br />
4、cmd切换到web-inf目录下执行<span style="color: #000000;">java -Djava</span><span style="color: #000000;">.</span><span style="color: #000000;">ext</span><span style="color: #000000;">.</span><span style="color: #000000;">dirs</span><span style="color: #000000;">=</span><span style="color: #000000;">lib org</span><span style="color: #000000;">.</span><span style="color: #000000;">apache</span><span style="color: #000000;">.</span><span style="color: #000000;">axis</span><span style="color: #000000;">.</span><span style="color: #000000;">client</span><span style="color: #000000;">.</span><span style="color: #000000;">AdminClient deploy</span><span style="color: #000000;">.</span><span style="color: #000000;">wsdd<br />
注意：如果你的tomcat不是默认的8080端口的话请使用(我在这里卡壳了)<br />
<span style="font-family: Arial Unicode MS;">java <span>-Djava.ext.dirs=lib </span><span>org.apache.axis.client.AdminClient -lhttp://</span><span>[主机地址]</span><span>/[</span><span>项目]</span><span>/services/AdminService deploy.wsdd</span></span><span style="font-family: SimSun;"><br />
会提示<span style="font-family: Arial;">Processing file deploy.wsdd 和 <span style="font-family: Arial;">Done processing ，然后可以看看 <span style="font-family: Arial;"><a href="http://localhost:8080/axis/servlet/AxisServlet"><span style="color: #336699;">http://localhost:8080/axis/servlet/AxisServlet</span></a> 是否发布成功(会多一个你刚开放的方法的wsdl)</span></span></span><br />
</span>5、此时就可以写一个客户端测了（为了方便部署，投了一个懒，我直接新建一个项目然后用axis的那个自带项目覆盖之，在一个项目里面放着，你不本地直接用就好了，你要知道soa干什么的），由于自己写了一个User bean，所以要牵扯到序列化问题，不了解的话看一下 <a href="http://www.cnblogs.com/mingzi/archive/2009/03/22/1419117.html">http://www.cnblogs.com/mingzi/archive/2009/03/22/1419117.html</a><br />
另外，javaeye网友<a href="http://www.javaeye.com/topic/349784">http://www.javaeye.com/topic/349784</a> 总结了一片axis开发指南，别人的经验可以看一下<br />
如果你的业务方法带参数而且有返回值，记得call.addParameter设置参数和call.setReturnType设置返回类型，否则会不能反序列化  could not find deserializer for type <br />
6、再有就是自定义异常，可以参见<a href="http://blog.csdn.net/chnic/category/371245.aspx">http://blog.csdn.net/chnic/category/371245.aspx</a>这个帖子lz发的pdf文档</span></p>
<p>看下效果吧.<br />
<a href="http://vzless.info/wp-content/uploads/2009/04/login.png"><img class="alignnone size-medium wp-image-279" title="login" src="http://vzless.info/wp-content/uploads/2009/04/login-300x184.png" alt="" width="300" height="184" /></a><a href="http://vzless.info/wp-content/uploads/2009/04/login-ok.png"><img class="alignnone size-medium wp-image-280" title="login-ok" src="http://vzless.info/wp-content/uploads/2009/04/login-ok.png" alt="" width="171" height="69" /></a><br />
<a href="http://vzless.info/wp-content/uploads/2009/04/exception1.png"><img class="alignnone size-medium wp-image-281" title="exception1" src="http://vzless.info/wp-content/uploads/2009/04/exception1-300x218.png" alt="" width="300" height="218" /></a><a href="http://vzless.info/wp-content/uploads/2009/04/exception2.png"><img class="alignnone size-medium wp-image-282" title="exception2" src="http://vzless.info/wp-content/uploads/2009/04/exception2-300x210.png" alt="" width="300" height="210" /></a></p>
<p><span style="color: #000000;"><br />
</span><span style="color: #000000;"><br />
</span></p>
<p> </p>
<div><span style="color: #000000;"> </span></div>
<p> </p>
<div><span style="color: #000000;"></span></div>
<p> </p>
<p><span style="color: #000000;"></p>
<p style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun"> </p>
<div><span style="color: #000000;"> </span></div>
<div><span style="color: #000000;"> </span></div>
<div><span style="color: #000000;"> </span></div>
<div><span style="color: #000000;"> </span></div>
<p><span style="color: #000000;"> </p>
<p></span> </p>
<p></span></p>
<p><span style="color: #000000;"><br />
 </span></p>
]]></content:encoded>
			<wfw:commentRss>http://vzless.info/2009/04/12/hkr-03-webservice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>为什么用struts</title>
		<link>http://vzless.info/2008/10/29/why-struts/</link>
		<comments>http://vzless.info/2008/10/29/why-struts/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 04:23:39 +0000</pubDate>
		<dc:creator>木乃y</dc:creator>
				<category><![CDATA[CS]]></category>

		<guid isPermaLink="false">http://vzless.info/?p=136</guid>
		<description><![CDATA[Struts告一段落，回顾一下，突然没感觉，究竟为什么给忘了，东西太多了&#8230;有点犯浑:),理了一下思路比较糙，只为加深印象。
不使用struts：业务逻辑和控制逻辑全部由servlet实现：既包括请求的分析又包括请求的处理：如取得表单数据—处理数据—然后转向，

//取得表单数据
		String username = request.getParameter&#40;&#34;xxx&#34;&#41;;
		//调用业务逻辑
		//转向相应的页面，显示出查询结果
		request.setAttribute&#40;&#34;xxxx&#34;, zzzz&#41;;
		//c.jsp,取出数据&#34;xxxx&#34;
	request.getRequestDispatcher&#40;&#34;/result.jsp&#34;&#41;.forward&#40;request, response&#41;;

进一步，可以把不同的请求放到一个servlet中，比如servlet配置用*.do匹配，拦截所有请求。分析定义比较规则的url，截取然后做出不同的处理和response

String requestURI = request.getRequestURI&#40;&#41;;
		System.out.println&#40;&#34;requestURI=&#34; + requestURI&#41;;
&#160;
		String path = requestURI.substring&#40;requestURI.indexOf&#40;&#34;/&#34;, 1&#41;, requestURI.length&#40;&#41;&#41;;
		path = path.substring&#40;0, path.indexOf&#40;&#34;.&#34;&#41;&#41;;
&#160;
		System.out.println&#40;&#34;path=&#34; + path&#41;;
		Action action = null;
		if &#40;&#34;/请求1&#34;.equals&#40;path&#41;&#41; &#123;
			//业务处理
//request.getRequestDispatcher(forwardPath).forward(request, response);
		&#125; else if &#40;&#34;/请求2&#34;.equals&#40;path&#41;&#41; &#123;
			//业务处理
//request.getRequestDispatcher(forwardPath).forward(request, response);
		&#125;
	//... ...

当然，你可以定义多个servlet分别处理在servlet里面只做调用，但是还无法把jsp表现层和业务逻辑分开，struts可以说把问题给我们分解了
引出struts的配置原理草稿（非真实配置，这是我们假想的处理方式，我们想这样把我们的请求处理，业务逻辑调用和展现分开）可以吗？可以 Struts就是这样做的！

&#160;

根据Web.xml里面的匹配规则截获请求url，和path匹配，（由struts的核心控制器Actionservlet分析），然后若必要调用用户自定义的业务逻辑控制器Action，完成后根据forward的name属性就像上面的xml草图一样，业务调用成功转向成功页面.jsp,失败转向失败失败.jsp。
这样jsp可以作为struts的表现层（V），struts负责用控制器调用业务逻辑组件，并负责控制器与视图技术（JSP、FreeMarker和Velocity等）的整合（C控制层）。
结果是：
业务逻辑控制器Action里面只负责调用我们已经实现好的功能类，自身并不实现业务逻辑，所以struts主要负责控制。当业务逻辑发生变化，struts并不需要改变，仍然只是调度。
业务（M）你只管好好干活就行了，干好了我struts好调用。
至于表现层，（V）以前的jsp页面内部包含大量java代码，一些业务处理也包含在其中，比如对对象的初始化等操作，使用struts后，实体类的定义只要哦我们按照javabean的规范，数据表单的处理都可以交给struts处理，表现层直接拿到（以前不停地getparameterBy….，比如使用taglib可以把我们的对象的各个属性拿到）actionform，根据属性名直接读取，还有表单验证之类也轻松
]]></description>
			<content:encoded><![CDATA[<p>Struts告一段落，回顾一下，突然没感觉，究竟为什么给忘了，东西太多了&#8230;有点犯浑:),理了一下思路比较糙，只为加深印象。<br />
不使用struts：业务逻辑和控制逻辑全部由servlet实现：既包括请求的分析又包括请求的处理：如取得表单数据—处理数据—然后转向，</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//取得表单数据</span>
		<span style="color: #003399;">String</span> username <span style="color: #339933;">=</span> request.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;xxx&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//调用业务逻辑</span>
		<span style="color: #666666; font-style: italic;">//转向相应的页面，显示出查询结果</span>
		request.<span style="color: #006633;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;xxxx&quot;</span>, zzzz<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//c.jsp,取出数据&quot;xxxx&quot;</span>
	request.<span style="color: #006633;">getRequestDispatcher</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/result.jsp&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">forward</span><span style="color: #009900;">&#40;</span>request, response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>进一步，可以把不同的请求放到一个servlet中，比如servlet配置用*.do匹配，拦截所有请求。分析定义比较规则的url，截取然后做出不同的处理和response</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span> requestURI <span style="color: #339933;">=</span> request.<span style="color: #006633;">getRequestURI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;requestURI=&quot;</span> <span style="color: #339933;">+</span> requestURI<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">String</span> path <span style="color: #339933;">=</span> requestURI.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span>requestURI.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>, requestURI.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		path <span style="color: #339933;">=</span> path.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, path.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;path=&quot;</span> <span style="color: #339933;">+</span> path<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Action</span> action <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/请求1&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>path<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//业务处理</span>
<span style="color: #666666; font-style: italic;">//request.getRequestDispatcher(forwardPath).forward(request, response);</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/请求2&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>path<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//业务处理</span>
<span style="color: #666666; font-style: italic;">//request.getRequestDispatcher(forwardPath).forward(request, response);</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">//... ...</span></pre></div></div>

<p>当然，你可以定义多个servlet分别处理在servlet里面只做调用，但是还无法把jsp表现层和业务逻辑分开，struts可以说把问题给我们分解了<br />
引出struts的配置原理草稿（非真实配置，这是我们假想的处理方式，我们想这样把我们的请求处理，业务逻辑调用和展现分开）可以吗？可以 Struts就是这样做的！</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">&nbsp;</pre></div></div>

<p>根据Web.xml里面的匹配规则截获请求url，和path匹配，（由struts的核心控制器Actionservlet分析），然后若必要调用用户自定义的业务逻辑控制器Action，完成后根据forward的name属性就像上面的xml草图一样，业务调用成功转向成功页面.jsp,失败转向失败失败.jsp。<br />
这样jsp可以作为struts的表现层（V），struts负责用控制器调用业务逻辑组件，并负责控制器与视图技术（JSP、FreeMarker和Velocity等）的整合（C控制层）。<br />
结果是：<span id="more-136"></span><br />
业务逻辑控制器Action里面只负责调用我们已经实现好的功能类，自身并不实现业务逻辑，所以struts主要负责控制。当业务逻辑发生变化，struts并不需要改变，仍然只是调度。<br />
业务（M）你只管好好干活就行了，干好了我struts好调用。<br />
至于表现层，（V）以前的jsp页面内部包含大量java代码，一些业务处理也包含在其中，比如对对象的初始化等操作，使用struts后，实体类的定义只要哦我们按照javabean的规范，数据表单的处理都可以交给struts处理，表现层直接拿到（以前不停地getparameterBy….，比如使用taglib可以把我们的对象的各个属性拿到）actionform，根据属性名直接读取，还有表单验证之类也轻松</p>
]]></content:encoded>
			<wfw:commentRss>http://vzless.info/2008/10/29/why-struts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>java的静态与动态代理</title>
		<link>http://vzless.info/2008/10/13/java-pattern-proxy/</link>
		<comments>http://vzless.info/2008/10/13/java-pattern-proxy/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 12:49:50 +0000</pubDate>
		<dc:creator>木乃y</dc:creator>
				<category><![CDATA[CS]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[代理模式]]></category>
		<category><![CDATA[动态代理]]></category>
		<category><![CDATA[静态代理]]></category>

		<guid isPermaLink="false">http://vzless.info/?p=102</guid>
		<description><![CDATA[即将学习框架所以算是比较认真的理解了一番代理并整理了下下。
代理模式是对象的结构型模式，代理模式给某一个对象提供了一个代理对象，并由代理对象控制对原对象的引用。 所以代理可以作函数执行前的拦截器，代理执行原对象方法的前后可以外加一些东西，典型应用：日志记录，在一 个方法执行成功或失败的前后都可以记录。
 Part I.静态代理
首先我们看静态代理的实现：定义接口：UserManager 抽象角色

package info.vzless.proxy;
public interface UserManager &#123;
    //添加用户
    public void addUser&#40;String username, String password&#41;;
    //修改用户
    public void modify&#40;String userId, String username, String password&#41;;
&#125;

真实角色UserManager接口的实现

package info.vzless.proxy;
public class UserManagerImpl implements UserManager &#123;
	public void addUser&#40;String username, String password&#41; &#123;
		//System.out.println(&#34;start---&#38;gt;&#38;gt;addUser() - username=&#34; + username);
		try &#123;
			//调用dao.......
			System.out.println&#40;&#34;UserManagerImpl.addUser()&#34;&#41;;
			//System.out.println(&#34;end---&#38;gt;&#38;gt;addUser() &#34;);
		&#125;catch&#40;Exception [...]]]></description>
			<content:encoded><![CDATA[<p>即将学习框架所以算是比较认真的理解了一番代理并整理了下下。</p>
<p>代理模式是对象的结构型模式，代理模式给某一个对象提供了一个代理对象，并由代理对象控制对原对象的引用。 所以代理可以作函数执行前的拦截器，代理执行原对象方法的前后可以外加一些东西，典型应用：日志记录，在一 个方法执行成功或失败的前后都可以记录。</p>
<h3> Part I.静态代理</h3>
<p>首先我们看静态代理的实现：定义接口：UserManager 抽象角色</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">info.vzless.proxy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> UserManager <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//添加用户</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addUser<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> username, <span style="color: #003399;">String</span> password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//修改用户</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> modify<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userId, <span style="color: #003399;">String</span> username, <span style="color: #003399;">String</span> password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>真实角色UserManager接口的实现</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">info.vzless.proxy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserManagerImpl <span style="color: #000000; font-weight: bold;">implements</span> UserManager <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addUser<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> username, <span style="color: #003399;">String</span> password<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//System.out.println(&quot;start---&amp;gt;&amp;gt;addUser() - username=&quot; + username);</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//调用dao.......</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UserManagerImpl.addUser()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">//System.out.println(&quot;end---&amp;gt;&amp;gt;addUser() &quot;);</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">lang</span>.<span style="color: #003399;">RuntimeException</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">//System.err.println(&quot;error---&amp;gt;&amp;gt;addUser()&quot;);</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> modify<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userId, <span style="color: #003399;">String</span> username, <span style="color: #003399;">String</span> password<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">//调用dao.......</span>
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UserManagerImpl.modify()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>具体的客户端调用：</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">info.vzless.proxy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Client <span style="color: #009900;">&#123;</span>
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * @param args
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//UserManager userManager = new UserManagerImpl();</span>
		UserManager userManager <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UserManagerImplProxy<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> UserManagerImpl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		userManager.<span style="color: #006633;">addUser</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;张三&quot;</span>, <span style="color: #0000ff;">&quot;123&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>后来可能因为业务需要，我们需要添加日志功能，好的，我们最笨的做法就是如UserManager接口的实现UserManagerImpl的addUser()方法中的注释部分一样，在每个方法的调用前后添加代码。软件开发有一个开闭原则(OCP)就是说对扩展开放，对修改关闭。所以我们不应该对原来的代码进行修改，因为修改后我们还要对原来的代 码改变进行测试，可谓劳民伤财。现在我们来用静态代理解决（仅对addUser方法举例说明）<span id="more-102"></span><br />
静态代理类</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">info.vzless.proxy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserManagerImplProxy <span style="color: #000000; font-weight: bold;">implements</span> UserManager <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> UserManager userManager<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> UserManagerImplProxy<span style="color: #009900;">&#40;</span>UserManager userManager<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">userManager</span> <span style="color: #339933;">=</span> userManager<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addUser<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> username, <span style="color: #003399;">String</span> password<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;start---&amp;gt;&amp;gt;addUser() - username=&quot;</span> <span style="color: #339933;">+</span> username<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">userManager</span>.<span style="color: #006633;">addUser</span><span style="color: #009900;">&#40;</span>username, password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;end---&amp;gt;&amp;gt;addUser() &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error---&amp;gt;&amp;gt;addUser()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> modify<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userId, <span style="color: #003399;">String</span> username, <span style="color: #003399;">String</span> password<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>这样，通过静态代理，代理拿到接口的实现的原对象，自己也实现同样的接口，并对其扩展，我们的客户端调<br />
用的 时候直接跟代理打交道时，代理会再通过拿到的原对象调用源对象的方法，而且在调用的前后加上我们扩展的内容 。</p>
<h3> part II.动态代理</h3>
<p>好的，这样我们事先对源代码无修改，遵照ocp原则，实现了我们的目的，但是如果原对象有10个，20个或者更多 的方法呢？我们要通过静态代理的话对每个方法都要这样做，工作量实相当大的，有没有好的方法呢？还好，jdk 为了解决这一问题给了我们这样的一个接口Interface InvocationHandler，要使用动态代理就必须实现这一接口动态代理类就是在运行时生成的class，在生成它时你必须提供一组interface给它，然后该class就宣称它实现了这些 interface，所以就可以把该class的实例当作这些interface中的任何一个来用。不过这个Dynamic Proxy其实就是一个 看不到的Proxy，它不会替你作实质性的工作，在生成它的实例时你必须提供一个handler</p>
<blockquote><p><span style="font-family: Tahoma">API摘要 java.lang.reflect</span></p>
<p>Interface InvocationHandler</p>
<p>InvocationHandler 是代理实例的调用处理程序 实现的接口。 每个代码实例都具有一个关联的调用处理程序。对代理实例调用方法时，将对方法调用进行编码并将其指派到它的 调用处理程序的 invoke 方法。</p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">info.vzless.proxy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.reflect.InvocationHandler</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.reflect.Method</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.reflect.Proxy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LogHandler <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">InvocationHandler</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Object</span> targetObject<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> createProxyObject<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> targetObject<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">targetObject</span> <span style="color: #339933;">=</span> targetObject<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span>
        <span style="color: #003399;">Proxy</span>.<span style="color: #006633;">newProxyInstance</span><span style="color: #009900;">&#40;</span>targetObject.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getClassLoader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
         targetObject.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getInterfaces</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
							      <span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> invoke<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> proxy, <span style="color: #003399;">Method</span> method, <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Throwable</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;start---&amp;gt;&amp;gt;&quot;</span> <span style="color: #339933;">+</span> method.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #0000ff;">&quot; + method.getName());
		}catch(Exception e) {
			System.err.println(&quot;</span>error<span style="color: #339933;">---&amp;</span>gt<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #0000ff;">&quot; + method.getName());
			throw e;
		}
		return ret;
	}
}</span></pre></div></div>

<p>1、该代理类的内部属性private Object targetObject 为Object类，实际使用时通过该类的createProxyObject方法对 其赋值；<br />
2、Proxy.newProxyInstance(targetObject.getClass().getClassLoader(), targetObject.getClass().getInterfaces(), this), 返回给客户端一个代理对象：先通过classloader拿到被代理对象也就是真实角色的，然后拿到被代理对象所实现的 接口（这一步就像我们静态代理中自己定义代理类时做的一样），this就是我们这个实现了InvocationHandler接口 的动态代理类，返回一个和被代理对象所实现的接口一样的对象。其中，第二个参数还可以实接口数组，如果被代理对象实现多个接口同样有效。</p>
<p>3、在该类还实现了invoke方法，该方法中的&#8221;method.invoke(sub,args)&#8221; 其实就是调用被代理对象的将要被执行的方法地方法-参数sub是实际的被代理对象方法&#8211;也就是调用此例中的addUseer等方法是要执行的，args为执行被代理对象方法sub的相应参数。通过动态代理类，我们可以在调用之前或之后执行加入一些相关操作。看下我们的客户端client2</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">info.vzless.proxy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Client <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		LogHandler logHandler <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LogHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		UserManager userManager <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>UserManager<span style="color: #009900;">&#41;</span>logHandler.<span style="color: #006633;">createProxyObject</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> UserManagerImpl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		userManager.<span style="color: #006633;">addUser</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;张三&quot;</span>, <span style="color: #0000ff;">&quot;123&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//userManager.modify(&quot;001&quot;, &quot;张三&quot;, &quot;123&quot;);</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>在客户端， 我们的logHandler.createProxyObject(被代理对象);可以轻松改变被代理对象，从而动态代理类无需改变 ，classloader就可以动态获得具体的被代理的对象实现的的接口，invoke调用具体的方法不像静态代理每个方法我 们都要写，即使被代理对象接口发生变化我们都不需要改变，非常灵活。</p>
<h3> part III代理应用：</h3>
<p>本例我们只是拿日志做演示，在调用之前或之后加入一些相关操作。其他如AOP(Aspect Oriented Programing)，授权机制等，在流行框架中非常重要（这是老师说的），所以为了学习 框架，自己整理摸索，算式理解的差不多了吧….</p>
<p>ps: 编辑此文，为贴代码格式问题绞尽脑汁，期间让我尝尽了“软回车- |l”的痛苦，长了见识。</p>
]]></content:encoded>
			<wfw:commentRss>http://vzless.info/2008/10/13/java-pattern-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在google reader里面阅读全文</title>
		<link>http://vzless.info/2008/10/08/gr-fullview/</link>
		<comments>http://vzless.info/2008/10/08/gr-fullview/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 14:38:23 +0000</pubDate>
		<dc:creator>木乃y</dc:creator>
				<category><![CDATA[CS]]></category>

		<guid isPermaLink="false">http://vzless.info/?p=64</guid>
		<description><![CDATA[一些博主为了点击量，rss设置为不是全文输出，就要从gr里面转到原始页面才好。情有可原，而且我也喜欢去别人的blog上留点言，所以也没什么。只是有时可能懒，所以不想跳来跳去。
想在google阅读全文是因为，因为一位博主的blog貌似被墙了，直接无法访问。我本想借助gr可以穿墙的功能，但没想博主没全文输出，所以才弄的。
环境：firefox 3.0
准备脚本：http://userscripts.org/scripts/review/9455，保存为 .js 文件
步骤
1.添加greasemonkey扩展（在ff里面直接搜就可以）
2.在工具-greasemonkey-新建用户脚本。输入名字，空间，描述等信息，并输入你想要应用待安装脚本的网址
此处为googlereader所用脚本所以应用到 http://www.google.com/reader/view/
3.确认，选择保存的js文件
就可以了，效果如下，看到preview按钮了吧？



想要编辑脚本，在工具-greasemonkey-管理用户脚本。
想要编辑时，点击编辑即可编辑选定的js文件，若找不到编辑器，手工指定一个如： notepad等文本编辑器即可
ps：结果，全文输出Preview有了 ，但毕竟不是通过google，而只是把原始网页嵌入到google reader里面，还是直接访问 穿墙功能还是没有，白忙活了，不过以后读不需要穿墙的文章方便了
==============
最近很忙也很迷茫，这blog都没时间打理了，任务没完成所以就没时间整理了，等等吧，有点可写的写点算复习吧
]]></description>
			<content:encoded><![CDATA[<p>一些博主为了点击量，rss设置为不是全文输出，就要从gr里面转到原始页面才好。情有可原，而且我也喜欢去别人的blog上留点言，所以也没什么。只是有时可能懒，所以不想跳来跳去。</p>
<p>想在google阅读全文是因为，因为一位博主的blog貌似被墙了，直接无法访问。我本想借助gr可以穿墙的功能，但没想博主没全文输出，所以才弄的。</p>
<p>环境：firefox 3.0</p>
<p>准备脚本：http://userscripts.org/scripts/review/9455，保存为 .js 文件</p>
<p>步骤</p>
<p>1.添加greasemonkey扩展（在ff里面直接搜就可以）</p>
<p>2.在工具-greasemonkey-新建用户脚本。输入名字，空间，描述等信息，并输入你想要应用待安装脚本的网址</p>
<p>此处为googlereader所用脚本所以应用到 http://www.google.com/reader/view/</p>
<p>3.确认，选择保存的js文件</p>
<p>就可以了，效果如下，看到preview按钮了吧？</p>
<p><a href="http://vzless.info/wp-content/uploads/2008/10/preview.jpg"><img class="alignnone size-medium wp-image-66" title="preview" src="http://vzless.info/wp-content/uploads/2008/10/preview.jpg" alt="" width="197" height="29" /></a></p>
<p><a href="http://vzless.info/wp-content/uploads/2008/10/preview.jpg"><br />
</a></p>
<p>想要编辑脚本，在工具-greasemonkey-管理用户脚本。</p>
<p>想要编辑时，点击编辑即可编辑选定的js文件，若找不到编辑器，手工指定一个如： notepad等文本编辑器即可</p>
<p>ps：结果，全文输出<span class="item-preview preview link">Preview有了 ，但毕竟不是通过google，而只是把原始网页嵌入到google reader里面，还是直接访问 穿墙功能还是没有，白忙活了，不过以后读不需要穿墙的文章方便了</span></p>
<p>==============</p>
<p>最近很忙也很迷茫，这blog都没时间打理了，任务没完成所以就没时间整理了，等等吧，有点可写的写点算复习吧</p>
]]></content:encoded>
			<wfw:commentRss>http://vzless.info/2008/10/08/gr-fullview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>hashcode()与equals()调用顺序问题</title>
		<link>http://vzless.info/2008/08/29/hashcode_equals/</link>
		<comments>http://vzless.info/2008/08/29/hashcode_equals/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 16:39:54 +0000</pubDate>
		<dc:creator>木乃y</dc:creator>
				<category><![CDATA[CS]]></category>

		<guid isPermaLink="false">http://vzless.info/?p=17</guid>
		<description><![CDATA[Object
hashCode()
public int hashCode()返回该对象的哈希码值。
hashCode 的常规协定是：
1&#62;对同一对象（信息不变前提下）多次调用 hashCode 方法时，必须一致地返回相同的整数，前提是将对象进行 equals 比较时所用的信息没有被修改。
2&#62;同一类两次执行可返回不同的hashcode
3&#62;如果根据 equals(Object) 方法，两个对象是相等的，那么对这两个对象中的每个对象调用 hashCode 方法都必须生成相同的整数结果。
4&#62;如果根据 equals(java.lang.Object) 方法，两个对象不相等，那么对这两个对象中的任一对象上调用 hashCode 方法不要求一定生成不同的整数结果。
注意第四点：不等的两对象可以返回同一hashcode
hashCode唯一的作用就是为支持数据结构中的哈希表结构而存在的，只有用到集合框架的 Hashtable、HashMap、HashSet的时候，才需要重载hashCode()方法
就拿困惑我的HashMap开杀吧
首先定义
Map m1 = new HashMap();
m1.put(new Name(&#8220;f1&#8243;),&#8221;aaa&#8221;);
m1.put(new Name(&#8220;f2&#8243;),&#8221;bbb&#8221;);
m1.put(new Name(&#8220;f1&#8243;),&#8221;bbb&#8221;);
hashmap通过键值索引，即put(k,v)中的k来判断重复与否，决定新添加的元素是否添加或覆盖
首先解压jdk下的src包观察下源码

java.util.HashMap
其中put方法判别k是否相等的语句如下
if (e.hash == hash &#38;&#38; ((k = e.key) == key &#124;&#124; key.equals(k)))
看到&#38;&#38;没？短路与。所以线比较hashcode是否相等，相等则继续按照object的equals或者我们重写的equals()来比较。此处Name类中我们定义了一个String name成员变量，好，我们重写hashcode方法，看看最上面Object的hashcode第一条，他也得调用equals来看这俩对象相等不，此处我们就得先调用String的equals了。当调用第三个put方法时，根据我们的意愿，new Name(&#8220;f1&#8243;)与new Name(&#8220;f1&#8243;)应该相等的(当然已经重写了equals方法)，可我们先保证hashcode相等人家put才理我们呢。
好了，重写hashcode先。Name的name实一个String，我们就返回一个String自己重写的hashcode吧(String根据自己的equals决定hahscode相等与否，葛吧？一层套一层)
@Override
public int hashCode() {
System.out.println(&#8220;===&#8221;+firstName.hashCode());
return firstName.hashCode();//这个对象当作为索引的时候会使用
}
这样只要两个对象的name值：字符串相等就会返回同一hashcode，接着再比较equals与否，最终判定键值k，剩下的就明了了，该咋咋地了
写这么多主要是想缕缕hahscode与hashcode与equals这两个方法的调用顺序，先前一直以为只要equals就可以，后来又有hahscode，心想咱先equals不也行啊？hash hash就是根据hash码来判断，不能再想了，不然又乱了
犹如新到一个城市一会儿分得清方向一会儿又分不清
睡觉zZ
]]></description>
			<content:encoded><![CDATA[<p>Object<br />
hashCode()<br />
public int hashCode()返回该对象的哈希码值。<br />
hashCode 的常规协定是：</p>
<p>1&gt;对同一对象（信息不变前提下）多次调用 hashCode 方法时，必须一致地返回相同的整数，前提是将对象进行 equals 比较时所用的信息没有被修改。<br />
2&gt;同一类两次执行可返回不同的hashcode<br />
3&gt;如果根据 equals(Object) 方法，两个对象是相等的，那么对这两个对象中的每个对象调用 hashCode 方法都必须生成相同的整数结果。<br />
4&gt;如果根据 equals(java.lang.Object) 方法，两个对象不相等，那么对这两个对象中的任一对象上调用 hashCode 方法不要求一定生成不同的整数结果。</p>
<p>注意第四点：不等的两对象可以返回同一hashcode<br />
hashCode唯一的作用就是为支持数据结构中的哈希表结构而存在的，只有用到集合框架的 Hashtable、HashMap、HashSet的时候，才需要重载hashCode()方法<br />
就拿困惑我的HashMap开杀吧<br />
首先定义<br />
Map m1 = new HashMap();</p>
<p>m1.put(new Name(&#8220;f1&#8243;),&#8221;aaa&#8221;);</p>
<p>m1.put(new Name(&#8220;f2&#8243;),&#8221;bbb&#8221;);</p>
<p>m1.put(new Name(&#8220;f1&#8243;),&#8221;bbb&#8221;);</p>
<p>hashmap通过键值索引，即put(k,v)中的k来判断重复与否，决定新添加的元素是否添加或覆盖<br />
首先解压jdk下的src包观察下源码<br />
<span id="more-17"></span><br />
java.util.HashMap<br />
其中put方法判别k是否相等的语句如下<br />
if (e.hash == hash &amp;&amp; ((k = e.key) == key || key.equals(k)))</p>
<p>看到&amp;&amp;没？短路与。所以线比较hashcode是否相等，相等则继续按照object的equals或者我们重写的equals()来比较。此处Name类中我们定义了一个String name成员变量，好，我们重写hashcode方法，看看最上面Object的hashcode第一条，他也得调用equals来看这俩对象相等不，此处我们就得先调用String的equals了。当调用第三个put方法时，根据我们的意愿，new Name(&#8220;f1&#8243;)与new Name(&#8220;f1&#8243;)应该相等的(当然已经重写了equals方法)，可我们先保证hashcode相等人家put才理我们呢。<br />
好了，重写hashcode先。Name的name实一个String，我们就返回一个String自己重写的hashcode吧(String根据自己的equals决定hahscode相等与否，葛吧？一层套一层)</p>
<p>@Override<br />
public int hashCode() {<br />
System.out.println(&#8220;===&#8221;+firstName.hashCode());<br />
return firstName.hashCode();//这个对象当作为索引的时候会使用<br />
}</p>
<p>这样只要两个对象的name值：字符串相等就会返回同一hashcode，接着再比较equals与否，最终判定键值k，剩下的就明了了，该咋咋地了</p>
<p>写这么多主要是想缕缕hahscode与hashcode与equals这两个方法的调用顺序，先前一直以为只要equals就可以，后来又有hahscode，心想咱先equals不也行啊？hash hash就是根据hash码来判断，不能再想了，不然又乱了<br />
犹如新到一个城市一会儿分得清方向一会儿又分不清<br />
睡觉zZ</p>
]]></content:encoded>
			<wfw:commentRss>http://vzless.info/2008/08/29/hashcode_equals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
