<?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>Myonlystar的个人网站</title>
	<atom:link href="http://qinshuwei.com/feed" rel="self" type="application/rss+xml" />
	<link>http://qinshuwei.com</link>
	<description>一份博客，一份人生，留给以后的自己。。。。</description>
	<lastBuildDate>Thu, 02 Sep 2010 13:22:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>我要写篇乱七八糟的文章</title>
		<link>http://qinshuwei.com/lqb.html</link>
		<comments>http://qinshuwei.com/lqb.html#comments</comments>
		<pubDate>Thu, 02 Sep 2010 12:58:22 +0000</pubDate>
		<dc:creator>Myonlystar</dc:creator>
				<category><![CDATA[心情随笔]]></category>

		<guid isPermaLink="false">http://qinshuwei.com/?p=1687</guid>
		<description><![CDATA[最近心情如同我的桌面一样越来越凌乱。很多次坐在电脑旁，都是有气无力的，莫非我已进入老年期了？心情糟糕，写文章也懒了排版了，爱咋地咋地吧，累不累。上午跟Mr.jia讨论了下项目的问题，如同听他讲数据库一样，收获不少，回头反思自己也很多，人站在高度不同，看到东西就是不一样啊。唉，平日生活中自己是一个很喜欢思考总结的人，怎么关键时刻掉链子呢，痛心疾首，痛定思痛。下午投了自己人生第一份网申简历，呜呼，路漫漫其修远兮，吾将上下而求索，投完后自己才发现一个严峻的问题：要是通知去面试，屁颠颠的来回五六百的车费，去到屁股没坐热，然后人家说你pass掉了，我该怎么办。不好不好，看来找工作也是一门学问，日子不好过啊。晚上吃的面条+茄子+西红柿+牛肉，撑了。坐在这里上下都不舒服。罗里罗嗦一大堆，突然想起前几天晚上10点半心血来潮去操场跑步，见操场人少，突发奇想，脱下凉鞋扔一边，赤脚上阵。结果，没两步，大事不妙，窜出一只黑狗，叼走一只鞋，又咬又啃，好家伙，几天没吃肉的样子，哥，鞋上没肉味吧。无计可施，只能光着脚丫，提着另一只鞋疯狂的追赶，好家伙，见我一靠近，叼着鞋就跑，等离我远了，又埋头又撕又啃，得意的样子，完全不顾我这个疲于奔命之徒。好吧，哥全当锻炼身体了，明天得到校保安科张贴一张大字报：关于我校野狗管理的若干意见。僵持了几个来回，我已完全心灰意冷，万念俱灰，愗足劲把手中的那只鞋扔了过去：都给你吧，哥不要了。不知是被我的大方迷倒，还是内心深深的愧疚，黑狗扔下口中的鞋，头也不回的，摇着尾巴屁颠屁颠的跑了。喜从悲来，看来真是舍不得孩子套不着狼啊。
提着凉鞋，11点的校园中，我慢悠悠的晃回宿舍，路上大家眼光很诧异，熟人的招呼，我淡定道：我足疗。
每天晚上看一集三国，坚持两个月了，看来不是人没有毅力，只是受到的诱惑不够。拍的很好，看到了很多导演关于三国的理解与解读，很好。不过我一直都不明白，草船借箭时，曹操为什么不用火箭射诸葛，真是扯淡。
外面开始下雨了（此处回到现实中，请读者注意），不喜欢下雨天，不写了。
]]></description>
			<content:encoded><![CDATA[<p>最近心情如同我的桌面一样越来越凌乱。很多次坐在电脑旁，都是有气无力的，莫非我已进入老年期了？心情糟糕，写文章也懒了排版了，爱咋地咋地吧，累不累。上午跟Mr.jia讨论了下项目的问题，如同听他讲数据库一样，收获不少，回头反思自己也很多，人站在高度不同，看到东西就是不一样啊。唉，平日生活中自己是一个很喜欢思考总结的人，怎么关键时刻掉链子呢，痛心疾首，痛定思痛。下午投了自己人生第一份网申简历，呜呼，路漫漫其修远兮，吾将上下而求索，投完后自己才发现一个严峻的问题：要是通知去面试，屁颠颠的来回五六百的车费，去到屁股没坐热，然后人家说你pass掉了，我该怎么办。不好不好，看来找工作也是一门学问，日子不好过啊。晚上吃的面条+茄子+西红柿+牛肉，撑了。坐在这里上下都不舒服。罗里罗嗦一大堆，突然想起前几天晚上10点半心血来潮去操场跑步，见操场人少，突发奇想，脱下凉鞋扔一边，赤脚上阵。结果，没两步，大事不妙，窜出一只黑狗，叼走一只鞋，又咬又啃，好家伙，几天没吃肉的样子，哥，鞋上没肉味吧。无计可施，只能光着脚丫，提着另一只鞋疯狂的追赶，好家伙，见我一靠近，叼着鞋就跑，等离我远了，又埋头又撕又啃，得意的样子，完全不顾我这个疲于奔命之徒。好吧，哥全当锻炼身体了，明天得到校保安科张贴一张大字报：关于我校野狗管理的若干意见。僵持了几个来回，我已完全心灰意冷，万念俱灰，愗足劲把手中的那只鞋扔了过去：都给你吧，哥不要了。不知是被我的大方迷倒，还是内心深深的愧疚，黑狗扔下口中的鞋，头也不回的，摇着尾巴屁颠屁颠的跑了。喜从悲来，看来真是舍不得孩子套不着狼啊。<br />
提着凉鞋，11点的校园中，我慢悠悠的晃回宿舍，路上大家眼光很诧异，熟人的招呼，我淡定道：我足疗。<br />
每天晚上看一集三国，坚持两个月了，看来不是人没有毅力，只是受到的诱惑不够。拍的很好，看到了很多导演关于三国的理解与解读，很好。不过我一直都不明白，草船借箭时，曹操为什么不用火箭射诸葛，真是扯淡。<br />
外面开始下雨了（此处回到现实中，请读者注意），不喜欢下雨天，不写了。</p>
]]></content:encoded>
			<wfw:commentRss>http://qinshuwei.com/lqb.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML中重复字段替换</title>
		<link>http://qinshuwei.com/xml%e4%b8%ad%e9%87%8d%e5%a4%8d%e5%ad%97%e6%ae%b5%e6%9b%bf%e6%8d%a2.html</link>
		<comments>http://qinshuwei.com/xml%e4%b8%ad%e9%87%8d%e5%a4%8d%e5%ad%97%e6%ae%b5%e6%9b%bf%e6%8d%a2.html#comments</comments>
		<pubDate>Tue, 27 Jul 2010 13:01:23 +0000</pubDate>
		<dc:creator>Myonlystar</dc:creator>
				<category><![CDATA[XML]]></category>
		<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://qinshuwei.com/?p=1657</guid>
		<description><![CDATA[
作为JAVA程序员，XML给我们带来的方便，大家都深有体会。我们经常会遇到这样的情况，把一个项目中需要变化的部分放在XML配置文件里（比如数据库中的用户名，密码，ip地址等信息），这样在我们部署或迁移项目时，只需要修改一下配置文件，重启一下Tomcat便可以了，无需重新编译类，充分体现了java作为跨平台解决方案的优越性。
但是如果XML文件中出现了大量重复性的东西怎么办？比如像下面的XSL文件，由于某种原因，我必须要给每个超链接补全服务器的地址http://localhost:8080/slw/show.jsp?webUrl=，如下图：

?Download DOWNLOAD.XML1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;
&#60;xsl:stylesheet xmlns:xsl=&#34;http://www.w3.org/1999/XSL/Transform&#34; version=&#34;1.0&#34;&#62;
	&#60;xsl:template match=&#34;/&#34;&#62;
		&#60;div class=&#34;wrap&#34;&#62;
		&#60;table&#62;
		&#60;tr&#62;
		&#60;xsl:for-each select=&#34;result/page/t&#34;&#62;
		&#60;td&#62;
			&#60;xsl:element name=&#34;a&#34;&#62;
				&#60;xsl:attribute name=&#34;href&#34;&#62;
				http://localhost:8080/slw/show.jsp?webUrl=&#60;xsl:value-of select=&#34;./@href&#34;/&#62;
				&#60;/xsl:attribute&#62;
				&#60;xsl:value-of select=&#34;.&#34;/&#62;
			&#60;/xsl:element&#62;
		&#60;/td&#62;
	   &#60;/xsl:for-each&#62;
				&#60;/tr&#62;
		&#60;/table&#62;
		............................................................................
		&#60;/div&#62;
&#60;/xsl:stylesheet&#62;


像这样的xsl文件，在我的项目中可能有10几个，而且每个文件中都有5、6处ip地址。一旦更换服务器，我就悲剧了，大量重复性的体力劳动，是每个程序员的悲哀。还好，DTD可以有效的解决这个问题。
DTD和Schema一样，以一种保证缩写XML文件正确的验证机制，不太了解的同学可以到网上搜索一下。DTD中的Entity实体可以有效解决上述问题。
ENTITY 语句用于在DTD 中定义实体，供与DTD 关联的XML 文档以及DTD 本身使用。ENTITY 提供缩写的条目，以便放入XML 文档。
具体解决方法如下：
首先我们定义一个外部的DTD文件constant.dtd:

?Download constant.dtd1
2
	&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;
	&#60;!ENTITY HREFURL &#34;http://localhost:8080/qdcc/show.jsp?webUrl=&#34;&#62;

然后在所需要使用的xml文件头部引入即可：

?Download constant.dtd1
&#60;!DOCTYPE result SYSTEM &#34;constant.dtd&#34;&#62;

上述完整例子如下：(注意XML文件中引入变量时，写法如下：&#038;变量名;)

?Download constant.dtd1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;
&#60;!DOCTYPE result SYSTEM &#34;constant.dtd&#34;&#62;
&#60;xsl:stylesheet xmlns:xsl=&#34;http://www.w3.org/1999/XSL/Transform&#34; version=&#34;1.0&#34;&#62;
	&#60;xsl:template match=&#34;/&#34;&#62;
		&#60;div class=&#34;wrap&#34;&#62;
		&#60;table&#62;
		&#60;tr&#62;
		&#60;xsl:for-each select=&#34;result/page/t&#34;&#62;
		&#60;td&#62;
			&#60;xsl:element name=&#34;a&#34;&#62;
				&#60;xsl:attribute name=&#34;href&#34;&#62;
				http://localhost:8080/slw/show.jsp?webUrl=&#60;xsl:value-of select=&#34;./@href&#34;/&#62;
				&#60;/xsl:attribute&#62;
				&#60;xsl:value-of select=&#34;.&#34;/&#62;
			&#60;/xsl:element&#62;
		&#60;/td&#62;
	   &#60;/xsl:for-each&#62;
				&#60;/tr&#62;
		&#60;/table&#62;
		............................................................................
		&#60;/div&#62;
&#60;/xsl:stylesheet&#62;


]]></description>
			<content:encoded><![CDATA[<div style="border-left: 5px solid rgb(221, 221, 221); margin: 15px 30px 0pt 10px; padding-left: 20px;">
作为JAVA程序员，XML给我们带来的方便，大家都深有体会。我们经常会遇到这样的情况，把一个项目中需要变化的部分放在XML配置文件里（比如数据库中的用户名，密码，ip地址等信息），这样在我们部署或迁移项目时，只需要修改一下配置文件，重启一下Tomcat便可以了，无需重新编译类，充分体现了java作为跨平台解决方案的优越性。<br/><br/><br />
但是如果XML文件中出现了大量重复性的东西怎么办？比如像下面的XSL文件，由于某种原因，我必须要给每个超链接补全服务器的地址<font color="#ff0000"><strong>http://localhost:8080/slw/show.jsp?webUrl=</strong></font>，如下图：<br/><br/></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://qinshuwei.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=1657&amp;download=DOWNLOAD.XML">DOWNLOAD.XML</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p16575"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p1657code5"><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;xsl:stylesheet</span> <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;wrap&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:for-each</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;result/page/t&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;href&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				http://localhost:8080/slw/show.jsp?webUrl=<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;./@href&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:element<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:for-each<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		............................................................................
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p><span id="more-1657"></span><br />
像这样的xsl文件，在我的项目中可能有10几个，而且每个文件中都有5、6处ip地址。一旦更换服务器，我就悲剧了，大量重复性的体力劳动，是每个程序员的悲哀。还好，<font color="#ff0000"><strong>DTD</strong></font>可以有效的解决这个问题。<br/><br/><br />
DTD和Schema一样，以一种保证缩写XML文件正确的验证机制，不太了解的同学可以到网上搜索一下。DTD中的Entity实体可以有效解决上述问题。<br />
<span style="background-color: rgb(0, 153, 255);"><font color="#ffffff"><strong>ENTITY 语句用于在DTD 中定义实体，供与DTD 关联的XML 文档以及DTD 本身使用。ENTITY 提供缩写的条目，以便放入XML 文档。</strong></font></span><br/><br/><br />
具体解决方法如下：<br />
首先我们定义一个外部的DTD文件constant.dtd:<br/><br/></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://qinshuwei.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=1657&amp;download=constant.dtd">constant.dtd</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p16576"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1657code6"><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;">&lt;!ENTITY HREFURL <span style="color: #ff0000;">&quot;http://localhost:8080/qdcc/show.jsp?webUrl=&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></td></tr></table></div>

<p>然后在所需要使用的xml文件头部引入即可：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://qinshuwei.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=1657&amp;download=constant.dtd">constant.dtd</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p16577"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1657code7"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE result SYSTEM &quot;constant.dtd&quot;&gt;</span></pre></td></tr></table></div>

<p>上述完整例子如下：(注意XML文件中引入变量时，写法如下：&#038;变量名;)<br/><br/></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://qinshuwei.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=1657&amp;download=constant.dtd">constant.dtd</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p16578"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p1657code8"><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: #00bbdd;">&lt;!DOCTYPE result SYSTEM &quot;constant.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;wrap&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:for-each</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;result/page/t&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;href&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				http://localhost:8080/slw/show.jsp?webUrl=<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;./@href&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:element<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:for-each<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		............................................................................
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://qinshuwei.com/xml%e4%b8%ad%e9%87%8d%e5%a4%8d%e5%ad%97%e6%ae%b5%e6%9b%bf%e6%8d%a2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>你坚持下来了，而别人坚持不下来，这就是你的资本</title>
		<link>http://qinshuwei.com/persis.html</link>
		<comments>http://qinshuwei.com/persis.html#comments</comments>
		<pubDate>Sun, 11 Jul 2010 05:43:14 +0000</pubDate>
		<dc:creator>Myonlystar</dc:creator>
				<category><![CDATA[好文转载]]></category>
		<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://qinshuwei.com/?p=1650</guid>
		<description><![CDATA[
中午一来到实验室就看到这篇文章，感觉写的真好。在这里转载一下，其中激起自己共鸣的地方，有红色标记出来了。蓝色的是自己的一些体会，补充上去的。

1、当最绝望的时候来临，你还是有选择的机会，你可以选择变得浮躁，也可以选择想办法改变现状。我们可以选择互相鼓励尝试走出困境，也可以选择一起抱怨摧毁旁人的希望让大家一起毁灭。
2、看到自己的同学或者其他熟人干得风生水起，就有些心不定了。就像长跑比赛，一开始大家都疯狂跑出去就你一个人慢吞吞的，就算你不想拿名次心里也会觉得别扭。但如果总是被外界环境或者别人的意思所左右的话，你会疲于奔命的。如果你想好了你想要的，就要心定，安心做好自己身边的事情。你就是每天打牌，只要能打成个高手，未必不能在这个社会安身立命，做什么并没有太大关系，关键是做好什么。
3、现在的情形有点像蛇蜕皮，或者说凤凰涅磐，本身都是到了一个瓶颈，每跨过一个瓶颈都是一段极端痛苦的经历，我不知道你有没有看过蛇蜕皮的样子，我只能用四个字来形容“极端痛苦”。跨过瓶颈的时间有长有短，传说玉皇大帝跨过一个瓶颈（他们叫做“劫”）要12万年。我唯有鼓励你继续坚持，相信“天道酬勤”，你坚持下来了，而别人坚持不下来，这就是你的资本。
4、要做到别人没有做到的事情，这样才能站稳脚跟，经过了“三年”你做事的水平应该和刚刚开始的时候是不一样的。如果只有“激情”，没有“结果”，这种人叫做“小白兔”，小白兔很可爱，但没用，团队领导不可能养一大堆小白兔。你觉得自己比别人强没用，要别人承认才行，喜欢你的人承认没用，要不喜欢你的人也承认才行。
5、对于不公平的现象，你能怎么办呢？愤怒，生气甚至自暴自弃只是在惩罚自己，让自己少活几年，那些不公平现象并不会有任何改变，社会已经不公平了，为什么还要惩罚自己？
6、得乙肝并不可怕，可怕的是这件事在你心里成为一个障碍，你一直背着这个包袱能跑多远跑多快？是的，你比一般人不幸，可能要比一般人承受多一点辛苦，可乙肝患者及携带者有1个多亿人，可没见有1亿多失业的，天还远没有塌下来，处境也远没有你担心的那么糟糕，“企业体检必被刷下来”，是别人吓唬你还是你吓唬自己？
7、无论什么时候，不要失去对生活的信心，不要让别人摧毁你的信心，那些失去了生活信心的人，比得了乙肝的人更悲惨。
8、是你把职场想简单了，而且你对于职场来说，太脆弱。这里本来就是一个狼多肉少适者生存的环境，我写的就是怎么在这样的环境里活下去，活得更好。你当然要知道上司会抢你的功劳，就像狼知道狮子会抢他的食物，难道知道狮子会抢就应该变得“十分阴险且沮丧，基本失去信心？”，因为知道狮子会抢，所以狼从不单独行动，野生动物永远都是饥饿的，从来没有可以安逸的时候，即使吃到一块肉也很快就会笑话掉，这就是职场生活，你何时见它们丧失过信心？知道上司会抢功劳，你总归会有办法的。至于你的沮丧，是你要练习克服的。
9、当你迷茫的时候，手边的事情就是好事情，不要犹豫，不要觉得可能自己会错过什么，你犹豫的时候，手边的事情就没做好，最后这辈子啥也没得到。所谓三鸟在林不如一鸟在手，做好一件事情比想做好三件事情可贵得多。“最”好的，实际上，经历过的就是“最”好的。再好的公司里也有不快乐的员工，再烂的公司也有快乐的时光。
11、如果能够做出成绩，销售的收入和未来都是要比技术好一些的，对于个性的磨练也有好处
12、想要什么，想清楚，选择，珍惜，一如对你的婚姻。
13、请相信任何一个选择都不会比另一个好或者差，虽然每个人到头来都会怀疑自己没有得到的才是最好的。
14、无论在哪个年龄，无论在哪个公司，你都要专注于发掘或者发展自己的“利用价值”，我们可以把利用价值分成三个档次：
第一个档次，忍别人不能忍的。
第二个档次，做别人不能做的。
第三个档次，想别人不能想的。
15、生活和工作还是要有所区别的，从你的文字当中看你的工作的起起伏伏完全影响了你的心情，这是不健康的。你首先要enjoy你的生活，而不是为了什么而勉强自己。很多人说，我这么做是为了这个，为了那个……但首先还是要为了自己，飞机上有句话，“在你试图帮助别人戴氧气面罩之前请先给自己戴好氧气面罩”（哪怕这个别人是你的亲人）为别人着想，先把自己的日子过好。
16、怎样获得快乐，获得财富，本来就是个相当复杂的问题，没有简单的回答。年轻人绝大多数没有事业没有钱，却有蓬勃的欲望，所以并不快乐，仍旧在人生的谷底徘徊，而我所想做的只是在帮忙想办法走出谷底，而不是到谷底把你背出来。
17、我觉得每条道路都可以走得很好，做什么不重要，重要的是怎么做。
18、要当贼就要有面临被抓的勇气，要赌博就要有倾家荡产的准备，要追求理想就要有承受失败的精神，要考虑下半辈子就要有适应环境的觉悟。你总是在悲观地看待问题，追求理想的时候想我下半辈子怎么办，追求物质的时候又觉得自己的个性受到了压抑。我们都是普通人，一生做好一件事就很了不起了，什么都要，什么都得不到
19、当你发现有些错误自己无论怎么努力都无法弥补的时候，那你就不要再去做无谓的努力，不要抱怨，学会去承担责任。真诚的去接受，认真的去反思。只有这样，犯下的错误才有意义。


]]></description>
			<content:encoded><![CDATA[<div style="border-left: 5px solid rgb(221, 221, 221); margin: 15px 30px 0pt 10px; padding-left: 20px;">
中午一来到实验室就看到这篇文章，感觉写的真好。在这里转载一下，其中激起自己共鸣的地方，有红色标记出来了。蓝色的是自己的一些体会，补充上去的。</p>
<div style="border-left: 5px solid rgb(221, 221, 221); margin: 15px 30px 0pt 10px; padding-left: 20px;">
<p>1、<font color="#ff0000"><strong>当最绝望的时候来临，你还是有选择的机会，你可以选择变得浮躁，也可以选择想办法改变现状。我们可以选择互相鼓励尝试走出困境，也可以选择一起抱怨摧毁旁人的希望让大家一起毁灭。</strong></font></p>
<p>2、看到自己的同学或者其他熟人干得风生水起，就有些心不定了。就像长跑比赛，一开始大家都疯狂跑出去就你一个人慢吞吞的，就算你不想拿名次心里也会觉得别扭。但如果总是被外界环境或者别人的意思所左右的话，你会疲于奔命的。<font color="#ff0000"><strong>如果你想好了你想要的，就要心定，安心做好自己身边的事情。</strong></font>你就是每天打牌，只要能打成个高手，未必不能在这个社会安身立命，做什么并没有太大关系，关键是做好什么。</p>
<p>3、现在的情形有点像蛇蜕皮，或者说凤凰涅磐，本身都是到了一个瓶颈，每跨过一个瓶颈都是一段极端痛苦的经历，我不知道你有没有看过蛇蜕皮的样子，我只能用四个字来形容“极端痛苦”。跨过瓶颈的时间有长有短，传说玉皇大帝跨过一个瓶颈（他们叫做“劫”）要12万年。<font color="#ff0000"><strong>我唯有鼓励你继续坚持，相信“天道酬勤”，你坚持下来了，而别人坚持不下来，这就是你的资本。</strong></font></p>
<p>4、<font color="#ff0000"><strong>要做到别人没有做到的事情，这样才能站稳脚跟，</strong></font>经过了“三年”你做事的水平应该和刚刚开始的时候是不一样的。如果只有“激情”，没有“结果”，这种人叫做“小白兔”，小白兔很可爱，但没用，团队领导不可能养一大堆小白兔。你觉得自己比别人强没用，要别人承认才行，喜欢你的人承认没用，要不喜欢你的人也承认才行。</p>
<p>5、对于不公平的现象，你能怎么办呢？愤怒，生气甚至自暴自弃只是在惩罚自己，让自己少活几年，那些不公平现象并不会有任何改变，社会已经不公平了，为什么还要惩罚自己？</p>
<p>6、得乙肝并不可怕，可怕的是这件事在你心里成为一个障碍，你一直背着这个包袱能跑多远跑多快？是的，你比一般人不幸，可能要比一般人承受多一点辛苦，可乙肝患者及携带者有1个多亿人，可没见有1亿多失业的，天还远没有塌下来，处境也远没有你担心的那么糟糕，“企业体检必被刷下来”，是别人吓唬你还是你吓唬自己？</p>
<p>7、<font color="#ff0000"><strong>无论什么时候，不要失去对生活的信心，不要让别人摧毁你的信心，那些失去了生活信心的人，比得了乙肝的人更悲惨。</strong></font></p>
<p>8、是你把职场想简单了，而且你对于职场来说，太脆弱。这里本来就是一个狼多肉少适者生存的环境，我写的就是怎么在这样的环境里活下去，活得更好。你当然要知道上司会抢你的功劳，就像狼知道狮子会抢他的食物，难道知道狮子会抢就应该变得“十分阴险且沮丧，基本失去信心？”，因为知道狮子会抢，所以狼从不单独行动，野生动物永远都是饥饿的，从来没有可以安逸的时候，即使吃到一块肉也很快就会笑话掉，这就是职场生活，你何时见它们丧失过信心？知道上司会抢功劳，你总归会有办法的。至于你的沮丧，是你要练习克服的。</p>
<p>9、<font color="#ff0000"><strong>当你迷茫的时候，手边的事情就是好事情，不要犹豫，不要觉得可能自己会错过什么，你犹豫的时候，手边的事情就没做好，最后这辈子啥也没得到。</strong></font>所谓三鸟在林不如一鸟在手，做好一件事情比想做好三件事情可贵得多。“最”好的，实际上，经历过的就是“最”好的。再好的公司里也有不快乐的员工，再烂的公司也有快乐的时光。</p>
<p>11、<font color="#ff0000"><strong>如果能够做出成绩，销售的收入和未来都是要比技术好一些的，对于个性的磨练也有好处</strong></font></p>
<p>12、想要什么，想清楚，选择，珍惜，一如对你的婚姻。</p>
<p>13、请相信任何一个选择都不会比另一个好或者差，虽然每个人到头来都会怀疑自己没有得到的才是最好的。</p>
<p>14、无论在哪个年龄，无论在哪个公司，你都要专注于发掘或者发展自己的“利用价值”，我们可以把利用价值分成三个档次：<br />
第一个档次，<font color="#ff0000"><strong>忍别人不能忍的。</strong></font><br />
第二个档次，做别人不能做的。<br />
第三个档次，想别人不能想的。</p>
<p>15、生活和工作还是要有所区别的，从你的文字当中看你的工作的起起伏伏完全影响了你的心情，这是不健康的。你首先要enjoy你的生活，而不是为了什么而勉强自己。很多人说，我这么做是为了这个，为了那个……但首先还是要为了自己，飞机上有句话，“在你试图帮助别人戴氧气面罩之前请先给自己戴好氧气面罩”（哪怕这个别人是你的亲人）为别人着想，先把自己的日子过好。</p>
<p>16、怎样获得快乐，获得财富，本来就是个相当复杂的问题，没有简单的回答。年轻人绝大多数没有事业没有钱，却有蓬勃的欲望，所以并不快乐，仍旧在人生的谷底徘徊，而我所想做的只是在帮忙想办法走出谷底，而不是到谷底把你背出来。</p>
<p>17、<font color="#ff0000"><strong>我觉得每条道路都可以走得很好，做什么不重要，重要的是怎么做。</strong></font></p>
<p>18、要当贼就要有面临被抓的勇气，要赌博就要有倾家荡产的准备，要追求理想就要有承受失败的精神，要考虑下半辈子就要有适应环境的觉悟。你总是在悲观地看待问题，追求理想的时候想我下半辈子怎么办，追求物质的时候又觉得自己的个性受到了压抑。<font color="#ff0000"><strong>我们都是普通人，一生做好一件事就很了不起了，什么都要，什么都得不到</strong></font></p>
<p style="background-color: rgb(0, 153, 255);"><font color="#ffffff"><strong>19、当你发现有些错误自己无论怎么努力都无法弥补的时候，那你就不要再去做无谓的努力，不要抱怨，学会去承担责任。真诚的去接受，认真的去反思。只有这样，犯下的错误才有意义。</strong></font></p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://qinshuwei.com/persis.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>HttpClient调用webservice</title>
		<link>http://qinshuwei.com/httpclient%e8%b0%83%e7%94%a8webservice.html</link>
		<comments>http://qinshuwei.com/httpclient%e8%b0%83%e7%94%a8webservice.html#comments</comments>
		<pubDate>Tue, 06 Jul 2010 13:31:47 +0000</pubDate>
		<dc:creator>Myonlystar</dc:creator>
				<category><![CDATA[WebService]]></category>

		<guid isPermaLink="false">http://qinshuwei.com/?p=1644</guid>
		<description><![CDATA[webservice调用总结

WebService以其不可比拟的优越性，在实际应用中，深受开发人员的欢迎。以前实验室的项目多是采用AXIS2作为webservice的解决方案，虽然其作为服务器端性能不错，但是其作为客户端存在稍显笨重，不易开发人员迅速上手的问题。接触了一段时间的HttpClient,于是最近尝试了一下通过httpclient，进行webservice客户端请求的调用，整个过程感觉效果不错。其实，webservice的本质就是一个遵循soap协议的远程调用过程。无论是AXIS2、Xfire还是httpclient，其只是帮我们封装好了一些调用方法，方便我们的调用。我们完全可以不通过这些方法，通过java提供的标准api，封装一个soap请求，进行http请求，完成我们的调用过程（这里讨论的不包含webservice发布问题）。这也是为什么基本上每一个面向公众的webservice商业应用都会提供Endpoint、Disco、WSDL三种参数入口：

代码示例：


?Download ClientOperate.java1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
/**
 * 类作用:演示了如何通过get、post以及httpclient封装soap请求三种方式调用webservice
 * @author qsw-Myonlystar @date 2010-7-6
 * @mail i@qinshuwei.com
 * 说明：调用的webservice为http://webservice.webxml.com.cn网站的火车站查询服务
 */
public class Test &#123;
	/**
	 * 通过get方式演示webservice
	 */
	private void getMethodWS&#40;&#41;&#123;
		DefaultHttpClient httpclient = new DefaultHttpClient&#40;&#41;;
		HttpGet httpget = new HttpGet&#40;&#34;http://webservice.webxml.com.cn/WebServices/TrainTimeWebService.asmx/getStationName&#34;&#41;;
		ResponseHandler&#60;String&#62; responseHandler = new BasicResponseHandler&#40;&#41;;
		String responseBody = null;
		try &#123;
			responseBody [...]]]></description>
			<content:encoded><![CDATA[<h2 style="background-color: rgb(0, 153, 255);"><font color="#ffffff">webservice调用总结</font></h2>
<div style="border-left: 5px solid rgb(221, 221, 221); margin: 15px 30px 0pt 10px; padding-left: 20px;">
WebService以其不可比拟的优越性，在实际应用中，深受开发人员的欢迎。以前实验室的项目多是采用<font color="#ff0000"><strong>AXIS2</strong></font>作为webservice的解决方案，虽然其作为服务器端性能不错，但是其作为客户端存在<font color="#ff0000"><strong>稍显笨重，不易开发人员迅速上手的问题</strong></font>。接触了一段时间的HttpClient,于是最近尝试了一下通过httpclient，进行webservice客户端请求的调用，整个过程感觉效果不错。其实，webservice的本质<font color="#ff0000"><strong>就是一个遵循soap协议的远程调用过程</strong></font>。无论是AXIS2、Xfire还是httpclient，其只是帮我们封装好了一些调用方法，方便我们的调用。<font color="#ff0000"><strong>我们完全可以不通过这些方法，通过java提供的标准api，封装一个soap请求，进行http请求，完成我们的调用过程</strong></font>（这里讨论的不包含webservice发布问题）。这也是为什么基本上每一个面向公众的webservice商业应用都会提供<font color="#ff0000"><strong>Endpoint、Disco、WSDL</strong></font>三种参数入口：
</div>
<h2 style="background-color: rgb(0, 153, 255);"><font color="#ffffff">代码示例：</font></h2>
<div style="border-left: 5px solid rgb(221, 221, 221); margin: 15px 30px 0pt 10px; padding-left: 20px;">

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://qinshuwei.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=1644&amp;download=ClientOperate.java">ClientOperate.java</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p164410"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
</pre></td><td class="code" id="p1644code10"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.UnsupportedEncodingException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.HttpEntity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.NameValuePair</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.ClientProtocolException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.ResponseHandler</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.entity.UrlEncodedFormEntity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.HttpGet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.HttpPost</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.entity.StringEntity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.impl.client.BasicResponseHandler</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.impl.client.DefaultHttpClient</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.message.BasicNameValuePair</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.protocol.HTTP</span><span style="color: #339933;">;</span>
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 类作用:演示了如何通过get、post以及httpclient封装soap请求三种方式调用webservice
 * @author qsw-Myonlystar @date 2010-7-6
 * @mail i@qinshuwei.com
 * 说明：调用的webservice为http://webservice.webxml.com.cn网站的火车站查询服务
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Test <span style="color: #009900;">&#123;</span>
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * 通过get方式演示webservice
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> getMethodWS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		DefaultHttpClient httpclient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		HttpGet httpget <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://webservice.webxml.com.cn/WebServices/TrainTimeWebService.asmx/getStationName&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ResponseHandler<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> responseHandler <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BasicResponseHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> responseBody <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;">try</span> <span style="color: #009900;">&#123;</span>
			responseBody <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpget, responseHandler<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>ClientProtocolException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</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: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</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>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>responseBody<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		httpclient.<span style="color: #006633;">getConnectionManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">shutdown</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: #008000; font-style: italic; font-weight: bold;">/**
	 * 通过post方式调用webservice
	 * @throws UnsupportedEncodingException
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> postMethodWS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		DefaultHttpClient httpclient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		HttpPost httpost <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost<span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">&quot;http://webservice.webxml.com.cn/WebServices/TrainTimeWebService.asmx/getStationAndTimeByTrainCode&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		List<span style="color: #339933;">&lt;</span>NameValuePair<span style="color: #339933;">&gt;</span> nvps <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>NameValuePair<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		nvps.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> BasicNameValuePair<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;TrainCode&quot;</span>,<span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		nvps.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> BasicNameValuePair<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UserID&quot;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		UrlEncodedFormEntity urlEntity <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;">try</span> <span style="color: #009900;">&#123;</span>
			urlEntity <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UrlEncodedFormEntity<span style="color: #009900;">&#40;</span>nvps,
					HTTP.<span style="color: #006633;">UTF_8</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><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aunsupportedencodingexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">UnsupportedEncodingException</span></a> e1<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</span>
			e1.<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>
		httpost.<span style="color: #006633;">setEntity</span><span style="color: #009900;">&#40;</span>urlEntity<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ResponseHandler<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> responseHandler <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BasicResponseHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> responseBody <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;">try</span> <span style="color: #009900;">&#123;</span>
			responseBody <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpost, responseHandler<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>ClientProtocolException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</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: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</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>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>responseBody<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		httpclient.<span style="color: #006633;">getConnectionManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">shutdown</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: #008000; font-style: italic; font-weight: bold;">/**
	 * 通过soap方式调用webservice
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> soapMethodWS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> soapRequestData <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;?xml version=<span style="color: #000099; font-weight: bold;">\&quot;</span>1.0<span style="color: #000099; font-weight: bold;">\&quot;</span> encoding=<span style="color: #000099; font-weight: bold;">\&quot;</span>utf-8<span style="color: #000099; font-weight: bold;">\&quot;</span>?&gt;&quot;</span>
				<span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;soap:Envelope xmlns:xsi=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span style="color: #000099; font-weight: bold;">\&quot;</span> xmlns:xsd=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.w3.org/2001/XMLSchema<span style="color: #000099; font-weight: bold;">\&quot;</span> xmlns:soap=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://schemas.xmlsoap.org/soap/envelope/<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span>
				<span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;soap:Body&gt;&quot;</span>
				<span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;getStationName xmlns=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://WebXml.com.cn/<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;&quot;</span>
				<span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/soap:Body&gt;&quot;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/soap:Envelope&gt;&quot;</span><span style="color: #339933;">;</span>
		DefaultHttpClient httpclient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		HttpPost httpost <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://webservice.webxml.com.cn/WebServices/TrainTimeWebService.asmx&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		httpost.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type&quot;</span>, <span style="color: #0000ff;">&quot;text/xml; charset=utf-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		HttpEntity entity <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;">try</span> <span style="color: #009900;">&#123;</span>
			entity <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringEntity<span style="color: #009900;">&#40;</span>soapRequestData<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><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aunsupportedencodingexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">UnsupportedEncodingException</span></a> e1<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</span>
			e1.<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> 
		httpost.<span style="color: #006633;">setEntity</span><span style="color: #009900;">&#40;</span>entity<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ResponseHandler<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> responseHandler <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BasicResponseHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> responseBody <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;">try</span> <span style="color: #009900;">&#123;</span>
			responseBody <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpost, responseHandler<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>ClientProtocolException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</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: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</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>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>responseBody<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		httpclient.<span style="color: #006633;">getConnectionManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">shutdown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * @param args
	 * @throws IOException
	 * @throws ClientProtocolException
	 */</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><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><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>
		Test t<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> Test<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		t.<span style="color: #006633;">getMethodWS</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;">//get方式测试</span>
		t.<span style="color: #006633;">soapMethodWS</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;">//soap方式测试</span>
		t.<span style="color: #006633;">postMethodWS</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;">//post方式测试</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://qinshuwei.com/httpclient%e8%b0%83%e7%94%a8webservice.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>《越光宝盒》，星爷你看了吗？</title>
		<link>http://qinshuwei.com/%e3%80%8a%e8%b6%8a%e5%85%89%e5%ae%9d%e7%9b%92%e3%80%8b%ef%bc%8c%e6%98%9f%e7%88%b7%e4%bd%a0%e7%9c%8b%e4%ba%86%e5%90%97%ef%bc%9f.html</link>
		<comments>http://qinshuwei.com/%e3%80%8a%e8%b6%8a%e5%85%89%e5%ae%9d%e7%9b%92%e3%80%8b%ef%bc%8c%e6%98%9f%e7%88%b7%e4%bd%a0%e7%9c%8b%e4%ba%86%e5%90%97%ef%bc%9f.html#comments</comments>
		<pubDate>Thu, 20 May 2010 13:49:37 +0000</pubDate>
		<dc:creator>Myonlystar</dc:creator>
				<category><![CDATA[乱侃一通]]></category>

		<guid isPermaLink="false">http://qinshuwei.com/?p=1610</guid>
		<description><![CDATA[曾经有一部痛彻心扉的喜剧，在几代青年前赴后继的追捧下，成为了永恒的传奇，一个时代的经典。大笑，流泪，然后是无尽的沉默，是无数人看后的反应。传奇的名字叫做&#8211;《月光宝盒》。
如今，16年过去了，导演刘镇伟，在尝试了无数的作品后，又给我们带来了一部新作品&#8211;《越光宝盒》。无奈观众总是怀旧，于似乎，众星云集的大片并不让观众买账，众口如一的评价：“贱”。网友的一通口诛笔伐，也只能让刘葡萄委屈道：不带这样玩我的。
我不想评价《越光宝盒》是否真的“贱”的如此一塌糊涂，我只想替刘葡萄道几句苦水，一个艺术家，如果他的作品达到了艺术巅峰，那么他以后只能走下坡路，也许这注定就是成功后的悲哀。就像刘葡萄一样，《仙履奇缘》，《月光宝盒》让他站上了一个时代的巅峰，然而事物都是两面的，巨大的成功的背后，总是万劫不复的阴影，就像当初看完《梦里花落知多少》后，我坚信郭敬明再也不会写出如此好的作品一样。人突破自己很难；葡萄也是如此，我们看到了勤勤恳恳的葡萄，总是在不停的尝试放下包袱，可惜换来的却是怀旧观众一如既往的责骂。这又能怪谁呢？江郎才尽，我看未必，高处不胜寒，升的太高，跌的自然会很痛。也许，让观众们彻底忘记自己，是葡萄唯一的解脱的办法。
曾经分享过一篇很经典的帖子，叫做还有个爱情叫大话西游，把狂爱大话西游系列的fans们的心声表现的淋漓尽致。看着《越》中朱茵一个人跑出来，总感觉心里怪怪的，盼望着，盼望着，可惜最后还是没出现。也许就像剧中说的那样：你活得就那么高尚吗？
记得很久以前看《无间道》时曾经跟朋友争论过一个问题：到底是演员更重要还是导演更重要（当然二者缺一不可）。电影到底是什么？在我看来，一部电影，其实就是导演在向我们讲述一个故事。我们看见的就是导演之所思的，是他对这个事物的认知与理解。剧本不好，导演可以改编；演员表演不到位，导演会不停的重来，总之，一切都活在导演的思想里。演员，剧本只是工具，是导演用来向观众传达思想的载体。就像软件开发中的designer，设计好所有的东西，coder只是一个工具，一个实现别人的思想的工具，不能有自己的任何想法。
我一直坚持我的观点，可惜那天我说不出话来，只因朋友问我：你说在《月光宝盒》，《仙履奇缘》里，谁是不可或缺的？
直到今天，还是无限怀念星爷，貌似香港近十年来的喜剧电影，能让我怀念起的也只有《少林足球》和《功夫》了；大好的才华，为什么就这样浪费了。还是那句话：自己真的就那么高尚吗？周围的人真的就那么贱吗？哪儿有那么多的使命要你去完成？怎么总是一副说教别人的嘴脸？有意思吗？难道一定要给你的铁杆fans们留下无尽的遗憾才过瘾吗？
后记：貌似这半年回来就没动过笔，不好啊不好啊。日志是好久以前看完《越光宝盒》写的。本来想自己ps个海报再贴出来，可惜可惜，水平有限，只能放弃啊。
]]></description>
			<content:encoded><![CDATA[<p>曾经有一部痛彻心扉的喜剧，在几代青年前赴后继的追捧下，成为了永恒的传奇，一个时代的经典。大笑，流泪，然后是无尽的沉默，是无数人看后的反应。传奇的名字叫做&#8211;<font color="#ff0000"><strong>《月光宝盒》</strong></font>。</p>
<p>如今，16年过去了，导演刘镇伟，在尝试了无数的作品后，又给我们带来了一部新作品&#8211;《越光宝盒》。无奈观众总是怀旧，于似乎，众星云集的大片并不让观众买账，众口如一的评价：“贱”。网友的一通口诛笔伐，也只能让刘葡萄委屈道：不带这样玩我的。</p>
<p>我不想评价《越光宝盒》是否真的“贱”的如此一塌糊涂，我只想替刘葡萄道几句苦水，一个艺术家，如果他的作品达到了艺术巅峰，那么他以后只能走下坡路，也许这注定就是成功后的悲哀。就像刘葡萄一样，《仙履奇缘》，《月光宝盒》让他站上了一个时代的巅峰，然而事物都是两面的，巨大的成功的背后，总是万劫不复的阴影，就像当初看完《梦里花落知多少》后，我坚信郭敬明再也不会写出如此好的作品一样。人突破自己很难；葡萄也是如此，我们看到了勤勤恳恳的葡萄，总是在不停的尝试放下包袱，可惜换来的却是怀旧观众一如既往的责骂。这又能怪谁呢？江郎才尽，我看未必，高处不胜寒，升的太高，跌的自然会很痛。也许，让观众们彻底忘记自己，是葡萄唯一的解脱的办法。</p>
<p>曾经分享过一篇很经典的帖子，叫做<a href="http://blog.renren.com/blog/31561970/428959340" style="color:#008d00"><strong>还有个爱情叫大话西游</strong></a>，把狂爱大话西游系列的fans们的心声表现的淋漓尽致。看着《越》中朱茵一个人跑出来，总感觉心里怪怪的，盼望着，盼望着，可惜最后还是没出现。也许就像剧中说的那样：你活得就那么高尚吗？</p>
<p>记得很久以前看《无间道》时曾经跟朋友争论过一个问题：到底是演员更重要还是导演更重要（当然二者缺一不可）。电影到底是什么？在我看来，一部电影，其实就是导演在向我们讲述一个故事。我们看见的就是导演之所思的，是他对这个事物的认知与理解。剧本不好，导演可以改编；演员表演不到位，导演会不停的重来，总之，一切都活在导演的思想里。演员，剧本只是工具，是导演用来向观众传达思想的载体。就像软件开发中的designer，设计好所有的东西，coder只是一个工具，一个实现别人的思想的工具，不能有自己的任何想法。</p>
<p>我一直坚持我的观点，可惜那天我说不出话来，只因朋友问我：你说在《月光宝盒》，《仙履奇缘》里，谁是不可或缺的？</p>
<p>直到今天，还是无限怀念星爷，貌似香港近十年来的喜剧电影，能让我怀念起的也只有《少林足球》和《功夫》了；大好的才华，为什么就这样浪费了。还是那句话：自己真的就那么高尚吗？周围的人真的就那么贱吗？哪儿有那么多的使命要你去完成？怎么总是一副说教别人的嘴脸？有意思吗？难道一定要给你的铁杆fans们留下无尽的遗憾才过瘾吗？</p>
<p><font color="#ff0000"><strong>后记：貌似这半年回来就没动过笔，不好啊不好啊。日志是好久以前看完《越光宝盒》写的。本来想自己ps个海报再贴出来，可惜可惜，水平有限，只能放弃啊。</strong></font></p>
]]></content:encoded>
			<wfw:commentRss>http://qinshuwei.com/%e3%80%8a%e8%b6%8a%e5%85%89%e5%ae%9d%e7%9b%92%e3%80%8b%ef%bc%8c%e6%98%9f%e7%88%b7%e4%bd%a0%e7%9c%8b%e4%ba%86%e5%90%97%ef%bc%9f.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>java中文乱码</title>
		<link>http://qinshuwei.com/java%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81.html</link>
		<comments>http://qinshuwei.com/java%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81.html#comments</comments>
		<pubDate>Thu, 01 Apr 2010 02:05:18 +0000</pubDate>
		<dc:creator>Myonlystar</dc:creator>
				<category><![CDATA[J2EE]]></category>

		<guid isPermaLink="false">http://qinshuwei.com/?p=1607</guid>
		<description><![CDATA[作为一个java程序员，你一定都经受过java中文乱码的摧残，尤其是Jsp中文显示，相信是每个初做J2EE人的必过的坎。更要命的是，代码上明明觉得都没有什么问题，可显示出来就是乱码,更有甚者，调试的时候好好的，当你兴冲冲的部署到服务器上时，乱码了，你也就傻眼了，贼郁闷。ps:还有一个问题，我一直都没想明白，为什么java设计者要把java流设计的如此复杂，每一次在做流的处理时，我都要查jdk文档，要不然云里雾里的。
最近手头上一个项目，其中牵扯了很多的编码的问题，整个流程从网页源码的抓取，document对象转化，xml生成，到字节流抽取，页面显示，其中还伴随着输入输出流的交换。更要命的是，这个项目三个模块是由不同人完成了。所以跑下一个流程，五花八门，屏幕一堆火星文。
好吧，我只好拿出一天的时间来读每个人的代码，然后解决这个问题。还好，项目不是很大，类不是很多，函数也不是很复杂，折腾到下午问题总算解决。一个字，累。我没有什么好办法，只能用一个接口，把所有抓取到的页面源码统一成utf-8格式，然后其他模块中每一个牵扯到字符流，编码的地方，我都加上utf-8硬编码。很累，不过还是有点收获，在这里总结下：
1、整个项目编码格式要统一。
大家不要笑，这是一个老生常谈的东西，但是我敢打包票，一个团队做出来的项目总会在某个地方出问题。比如要用UTF-8编码，那你每一个文件都要加上UTF-8编码，包括java类,xml文件,jsp,html页面等等，总之所有的文件，最好借助于IDE工具进行统一编码。其中还要注意一点，如果用UTF-8编码，那么每一处都要用大写，而不要有的地方，用utf-8,有的用UTF-8。因为残酷的经验告诉我们，这在一个页面包含另一个页面时，会出问题的。
2、禁忌toString(),getBytes(),new String().
通常遇到字符乱码时，每个人都会说，我这里是好好的，不信你看。但是，请你相信，也许问题就出在你认为对的地方。项目是一个整体，如果你不遵守项目组制定的规范，那么在你的模块里再好也是徒劳无益的。所以在使用toString(),getBytes(),new String()这些函数时，请一定设定它们的编码格式，比如getBytes(&#8221;UTF-8&#8243;)，toString(&#8221;UTF-8&#8243;)，如果缺省，系统会采用java默认的编码格式，这往往就为你的团队埋下了苦果。
3、请你相信htmlStr=new   String(htmlStr.getBytes(&#8221;utf-8&#8243;),&#8221;utf-8&#8243;);
真的，有时候你得到的字符串明明是utf-8的，但是打印出来就是乱码，好吧我不知道这是为什么，但你可以试一下htmlStr=new   String(htmlStr.getBytes(&#8221;UTF-8&#8243;),&#8221;UTF-8&#8243;);也许问题就会解决。
总之，解决java中文乱码是一个细活，规范的开发手册+良好的编程习惯+细心也许会让你不至于有些时候手忙脚乱。
]]></description>
			<content:encoded><![CDATA[<p>作为一个java程序员，你一定都经受过java中文乱码的摧残，尤其是Jsp中文显示，相信是每个初做J2EE人的必过的坎。更要命的是，代码上明明觉得都没有什么问题，可显示出来就是乱码,更有甚者，调试的时候好好的，当你兴冲冲的部署到服务器上时，乱码了，你也就傻眼了，贼郁闷。ps:还有一个问题，我一直都没想明白，为什么java设计者要把java流设计的如此复杂，每一次在做流的处理时，我都要查jdk文档，要不然云里雾里的。</p>
<p>最近手头上一个项目，其中牵扯了很多的编码的问题，整个流程从网页源码的抓取，document对象转化，xml生成，到字节流抽取，页面显示，其中还伴随着输入输出流的交换。更要命的是，这个项目三个模块是由不同人完成了。所以跑下一个流程，五花八门，屏幕一堆火星文。</p>
<p>好吧，我只好拿出一天的时间来读每个人的代码，然后解决这个问题。还好，项目不是很大，类不是很多，函数也不是很复杂，折腾到下午问题总算解决。一个字，累。我没有什么好办法，<span style="color: #ff0000;"><strong>只能用一个接口，把所有抓取到的页面源码统一成utf-8格式，然后其他模块中每一个牵扯到字符流，编码的地方，我都加上utf-8硬编码。</strong></span>很累，不过还是有点收获，在这里总结下：</p>
<h2 style="background-color: #99cc00;">1、整个项目编码格式要统一。</h2>
<p>大家不要笑，这是一个老生常谈的东西，但是我敢打包票，一个团队做出来的项目总会在某个地方出问题。比如要用UTF-8编码，那你每一个文件都要加上UTF-8编码，包括java类,xml文件,jsp,html页面等等，总之所有的文件，最好借助于IDE工具进行统一编码。其中还要注意一点，<span style="color: #ff0000;"><strong>如果用UTF-8编码，那么每一处都要用大写，而不要有的地方，用utf-8,有的用UTF-8。</strong></span>因为残酷的经验告诉我们，这在一个页面包含另一个页面时，会出问题的。</p>
<h2 style="background-color: #99cc00;">2、禁忌toString(),getBytes(),new String().</h2>
<p>通常遇到字符乱码时，每个人都会说，我这里是好好的，不信你看。但是，请你相信，也许问题就出在你认为对的地方。项目是一个整体，如果你不遵守项目组制定的规范，那么在你的模块里再好也是徒劳无益的。所以在使用toString(),getBytes(),new String()这些函数时，请一定设定它们的编码格式，比如<span style="color: #ff0000;"><strong>getBytes(&#8221;UTF-8&#8243;)，toString(&#8221;UTF-8&#8243;)，</strong></span>如果缺省，系统会采用java默认的编码格式，这往往就为你的团队埋下了苦果。</p>
<h2 style="background-color: #99cc00;">3、请你相信htmlStr=new   String(htmlStr.getBytes(&#8221;utf-8&#8243;),&#8221;utf-8&#8243;);</h2>
<p>真的，有时候你得到的字符串明明是utf-8的，但是打印出来就是乱码，好吧我不知道这是为什么，但你可以试一下<span style="color: #ff0000;"><strong>htmlStr=new   String(htmlStr.getBytes(&#8221;UTF-8&#8243;),&#8221;UTF-8&#8243;);</strong></span>也许问题就会解决。</p>
<p>总之，解决java中文乱码是一个细活，<span style="color: #ff0000;"><strong>规范的开发手册+良好的编程习惯+细心</strong></span>也许会让你不至于有些时候手忙脚乱。</p>
]]></content:encoded>
			<wfw:commentRss>http://qinshuwei.com/java%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>转：中国佛学66句震撼世界的禅语</title>
		<link>http://qinshuwei.com/%e8%bd%ac%ef%bc%9a%e4%b8%ad%e5%9b%bd%e4%bd%9b%e5%ad%a666%e5%8f%a5%e9%9c%87%e6%92%bc%e4%b8%96%e7%95%8c%e7%9a%84%e7%a6%85%e8%af%ad.html</link>
		<comments>http://qinshuwei.com/%e8%bd%ac%ef%bc%9a%e4%b8%ad%e5%9b%bd%e4%bd%9b%e5%ad%a666%e5%8f%a5%e9%9c%87%e6%92%bc%e4%b8%96%e7%95%8c%e7%9a%84%e7%a6%85%e8%af%ad.html#comments</comments>
		<pubDate>Mon, 22 Mar 2010 12:54:03 +0000</pubDate>
		<dc:creator>Myonlystar</dc:creator>
				<category><![CDATA[好文转载]]></category>

		<guid isPermaLink="false">http://qinshuwei.com/?p=1601</guid>
		<description><![CDATA[周末分享了一个视频永不言弃，感触颇多；有时候我们总认为自己做不到，总觉得梦想好遥远，其实是因为我们一直都在盯着目标，用遥远的希冀的梦去蚕食我们的信心。也许，低下头，蒙上眼睛，一步一步脚踏实地，成功就不在遥远。佛说过：
     1.人之所以痛苦，在于追求错误的东西。
　　2.如果你不给自己烦恼，别人也永远不可能给你烦恼。因为你自己的内心，你放不下。
　　3.你永远要感谢给你逆境的众生。 
　　4.你永远要宽恕众生，不论他有多坏，甚至他伤害过你，你一定要放下，才能得到真正的快乐。
　　5.当你快乐时，你要想这快乐不是永恒的。当你痛苦时，你要想这痛苦也不是永恒的。
　　6.今日的执著，会造成明日的后悔。
　　7.你可以拥有爱，但不要执著，因为分离是必然的。
　　8.不要浪费你的生命在你一定会后悔的地方上。
　　9.你什么时候放下，什么时候就没有烦恼。
　　10.每一种创伤，都是一种成熟。
　　11.狂妄的人有救，自卑的人没有救，认识自己，降伏自己，改变自己，才能改变别人。
　　12.你不要一直不满人家，你应该一直检讨自己才对。不满人家，是苦了你自己。
　　13.一个人如果不能从内心去原谅别人，那他就永远不会心安理得。
　　14.心中装满着自己的看法与想法的人，永远听不见别人的心声。
　　15.毁灭人只要一句话，培植一个人却要千句话，请你多口下留情。
　　16.根本不必回头去看咒骂你的人是谁？如果有一条疯狗咬你一口，难道你也要趴下去反咬他一口吗？
　　17.永远不要浪费你的一分一秒，去想任何你不喜欢的人。
　　18.请你用慈悲心和温和的态度，把你的不满与委屈说出来，别人就容易接受。
　　19.同样的瓶子，你为什么要装毒药呢？同样的心里，你为什么要充满着烦恼呢？
　　20.得不到的东西，我们会一直以为他是美好的，那是因为你对他了解太少，没有时间与他相处在一起。当有一天，你深入了解后，你会发现原不是你想像中的那么美好。
　　21.活着一天，就是有福气，就该珍惜。当我哭泣我没有鞋子穿的时候，我发现有人却没有脚。
　　22.多一分心力去注意别人，就少一分心力反省自己，你懂吗？
　　23.憎恨别人对自己是一种很大的损失。
　  24.每一个人都拥有生命，但并非每个人都懂得生命，乃至于珍惜生命。不了解生命的人，生命对他来说，是一种惩罚。
　　25.情执是苦恼的原因，放下情执，你才能得到自在 
　　26.不要太肯定自己的看法，这样子比较少后悔。
　　27.当你对自己诚实的时候，世界上没有人能够欺骗得了你。
　　28.用伤害别人的手段来掩饰自己缺点的人，是可耻的。
　　29.默默的关怀与祝福别人，那是一种无形的布施。
　　30.不要刻意去猜测他人的想法，如果你没有智慧与经验的正确判断，通常都会有错误的。
　　31.要了解一个人，只需要看他的出发点与目的地是否相同，就可以知道他是否真心的。
　　32.人生的真理，只是藏在平淡无味之中。
　　33.不洗澡的人，硬擦香水是不会香的。名声与尊贵，是来自于真才实学的。有德自然香。
　　34.时间总会过去的，让时间流走你的烦恼吧！
　　35.你硬要把单纯的事情看得很严重，那样子你会很痛苦。 
　　36.永远扭曲别人善意的人，无药可救。 
　　37.说一句谎话，要编造十句谎话来弥补，何苦呢？ 
　　38.白白的过一天，无所事事，就像犯了窃盗罪一样 
　　39.广结众缘，就是不要去伤害任何一个人。
　　40.沉默是毁谤最好的答覆。 
　　41.对人恭敬，就是在庄严你自己。
　　42.拥有一颗无私的爱心，便拥有了一切。
　　43.来是偶然的，走是必然的。所以你必须，随缘不变，不变随缘。 
　　44.慈悲是你最好的武器。
　　45.只要面对现实，你才能超越现实。
　　46.良心是每一个人最公正的审判官，你骗得了别人，却永远骗不了你自己的良心。
　　47.不懂得自爱的人，是没有能力去爱别人的。
　　48.有时候我们要冷静问问自已，我们在追求什么？我们活着为了什么？
　　49.不要因为小小的争执，远离了你至亲的好友，也不要因为小小的怨恨，忘记了别人的大恩。
　　50.感谢上苍我所拥有的，感谢上苍我所没有的。
　　51.凡是能站在别人的角度为他人着想，这个就是慈悲。
　　52.说话不要有攻击性，不要有杀伤力，不夸已能，不扬人恶，自然能化敌为友。
　　53.诚实的面对你内心的矛盾和污点，不要欺骗你自己。
　　54.因果不曾亏欠过我们什么，所以请不要抱怨。
　　55.大多数的人一辈子只做了三件事；自欺、欺人、被人欺。
　　56.心是最大的骗子，别人能骗你一时，而它却会骗你一辈子 
　　57.只要自觉心安，东西南北都好。如有一人未度，切莫自己逃了。
　　58.当你手中抓住一件东西不放时，你只能拥有这件东西，如果你肯放手，你就有机会选择别的。人的心若死执自己的观念，不肯放下，那么他的智慧也只能达到某种程度而已
　　59.如果你能够平平安安的渡过一天，那就是一种福气了。多少人在今天已经见不到明天的太阳，多少人在今天已经成了残废，多少人在今天已经失去了自由，多少人在今天已经家破人亡。
　　60.你有你的生命观，我有我的生命观，我不干涉你。只要我能，我就感化你。如果不能，那我就认命。
　　61.你希望掌握永恒，那你必须控制现在。
　　62.恶口永远不要出自于我们的口中，不管他有多坏，有多恶。你愈骂他，你的心就被污染了，你要想，他就是你的善知识。
　　63.别人可以违背因果，别人可以害我们，打我们，毁谤我们。可是我们不能因此而憎恨别人，为什么？我们一定要保有一颗完整的本性和一颗清净的心。
　　64.如果一个人没有苦难的感受，就不容易对他人给予同情。你要学救苦救难的精神，就得先受苦受难。
　　65.世界原本就不是属于你，因此你用不着抛弃，要抛弃的是一切的执著。万物皆为我所用，但非我所属。
　　66.虽然我们不能改变周遭的世界，我们就只好改变自己，用慈悲心和智慧心来面对这一切。
]]></description>
			<content:encoded><![CDATA[<p>周末分享了一个视频<a href="http://v.youku.com/v_show/id_XMTQ3MzU3NTQ4.html" style="color:#ff0000"><strong>永不言弃</strong></a>，感触颇多；有时候我们总认为自己做不到，总觉得梦想好遥远，其实是因为我们一直都在盯着目标，用遥远的希冀的梦去蚕食我们的信心。也许，低下头，蒙上眼睛，一步一步脚踏实地，成功就不在遥远。佛说过：</p>
<p>     1.人之所以痛苦，在于追求错误的东西。</p>
<p>　　2.如果你不给自己烦恼，别人也永远不可能给你烦恼。因为你自己的内心，你放不下。</p>
<p>　　3.你永远要感谢给你逆境的众生。 </p>
<p>　　4.你永远要宽恕众生，不论他有多坏，甚至他伤害过你，你一定要放下，才能得到真正的快乐。</p>
<p>　　5.当你快乐时，你要想这快乐不是永恒的。当你痛苦时，你要想这痛苦也不是永恒的。</p>
<p>　　6.今日的执著，会造成明日的后悔。</p>
<p>　　7.你可以拥有爱，但不要执著，因为分离是必然的。</p>
<p>　　8.不要浪费你的生命在你一定会后悔的地方上。</p>
<p>　　9.你什么时候放下，什么时候就没有烦恼。</p>
<p>　　10.每一种创伤，都是一种成熟。</p>
<p>　　11.狂妄的人有救，自卑的人没有救，认识自己，降伏自己，改变自己，才能改变别人。</p>
<p>　　12.你不要一直不满人家，你应该一直检讨自己才对。不满人家，是苦了你自己。</p>
<p>　　13.一个人如果不能从内心去原谅别人，那他就永远不会心安理得。</p>
<p>　　14.心中装满着自己的看法与想法的人，永远听不见别人的心声。</p>
<p>　　15.毁灭人只要一句话，培植一个人却要千句话，请你多口下留情。</p>
<p>　　16.根本不必回头去看咒骂你的人是谁？如果有一条疯狗咬你一口，难道你也要趴下去反咬他一口吗？</p>
<p>　　17.永远不要浪费你的一分一秒，去想任何你不喜欢的人。</p>
<p>　　18.请你用慈悲心和温和的态度，把你的不满与委屈说出来，别人就容易接受。</p>
<p>　　19.同样的瓶子，你为什么要装毒药呢？同样的心里，你为什么要充满着烦恼呢？</p>
<p>　　20.得不到的东西，我们会一直以为他是美好的，那是因为你对他了解太少，没有时间与他相处在一起。当有一天，你深入了解后，你会发现原不是你想像中的那么美好。</p>
<p>　　21.活着一天，就是有福气，就该珍惜。当我哭泣我没有鞋子穿的时候，我发现有人却没有脚。</p>
<p>　　22.多一分心力去注意别人，就少一分心力反省自己，你懂吗？</p>
<p>　　23.憎恨别人对自己是一种很大的损失。</p>
<p>　  24.每一个人都拥有生命，但并非每个人都懂得生命，乃至于珍惜生命。不了解生命的人，生命对他来说，是一种惩罚。</p>
<p>　　25.情执是苦恼的原因，放下情执，你才能得到自在 </p>
<p>　　26.不要太肯定自己的看法，这样子比较少后悔。</p>
<p>　　27.当你对自己诚实的时候，世界上没有人能够欺骗得了你。</p>
<p>　　28.用伤害别人的手段来掩饰自己缺点的人，是可耻的。</p>
<p>　　29.默默的关怀与祝福别人，那是一种无形的布施。</p>
<p>　　30.不要刻意去猜测他人的想法，如果你没有智慧与经验的正确判断，通常都会有错误的。</p>
<p>　　31.要了解一个人，只需要看他的出发点与目的地是否相同，就可以知道他是否真心的。</p>
<p>　　32.人生的真理，只是藏在平淡无味之中。</p>
<p>　　33.不洗澡的人，硬擦香水是不会香的。名声与尊贵，是来自于真才实学的。有德自然香。</p>
<p>　　34.时间总会过去的，让时间流走你的烦恼吧！</p>
<p>　　35.你硬要把单纯的事情看得很严重，那样子你会很痛苦。 </p>
<p>　　36.永远扭曲别人善意的人，无药可救。 </p>
<p>　　37.说一句谎话，要编造十句谎话来弥补，何苦呢？ </p>
<p>　　38.白白的过一天，无所事事，就像犯了窃盗罪一样 </p>
<p>　　39.广结众缘，就是不要去伤害任何一个人。</p>
<p>　　40.沉默是毁谤最好的答覆。 </p>
<p>　　41.对人恭敬，就是在庄严你自己。</p>
<p>　　42.拥有一颗无私的爱心，便拥有了一切。</p>
<p>　　43.来是偶然的，走是必然的。所以你必须，随缘不变，不变随缘。 </p>
<p>　　44.慈悲是你最好的武器。</p>
<p>　　45.只要面对现实，你才能超越现实。</p>
<p>　　46.良心是每一个人最公正的审判官，你骗得了别人，却永远骗不了你自己的良心。</p>
<p>　　47.不懂得自爱的人，是没有能力去爱别人的。</p>
<p>　　48.有时候我们要冷静问问自已，我们在追求什么？我们活着为了什么？</p>
<p>　　49.不要因为小小的争执，远离了你至亲的好友，也不要因为小小的怨恨，忘记了别人的大恩。</p>
<p>　　50.感谢上苍我所拥有的，感谢上苍我所没有的。</p>
<p>　　51.凡是能站在别人的角度为他人着想，这个就是慈悲。</p>
<p>　　52.说话不要有攻击性，不要有杀伤力，不夸已能，不扬人恶，自然能化敌为友。</p>
<p>　　53.诚实的面对你内心的矛盾和污点，不要欺骗你自己。</p>
<p>　　54.因果不曾亏欠过我们什么，所以请不要抱怨。</p>
<p>　　55.大多数的人一辈子只做了三件事；自欺、欺人、被人欺。</p>
<p>　　56.心是最大的骗子，别人能骗你一时，而它却会骗你一辈子 </p>
<p>　　57.只要自觉心安，东西南北都好。如有一人未度，切莫自己逃了。</p>
<p>　　58.当你手中抓住一件东西不放时，你只能拥有这件东西，如果你肯放手，你就有机会选择别的。人的心若死执自己的观念，不肯放下，那么他的智慧也只能达到某种程度而已</p>
<p>　　59.如果你能够平平安安的渡过一天，那就是一种福气了。多少人在今天已经见不到明天的太阳，多少人在今天已经成了残废，多少人在今天已经失去了自由，多少人在今天已经家破人亡。</p>
<p>　　60.你有你的生命观，我有我的生命观，我不干涉你。只要我能，我就感化你。如果不能，那我就认命。</p>
<p>　　61.你希望掌握永恒，那你必须控制现在。</p>
<p>　　62.恶口永远不要出自于我们的口中，不管他有多坏，有多恶。你愈骂他，你的心就被污染了，你要想，他就是你的善知识。</p>
<p>　　63.别人可以违背因果，别人可以害我们，打我们，毁谤我们。可是我们不能因此而憎恨别人，为什么？我们一定要保有一颗完整的本性和一颗清净的心。</p>
<p>　　64.如果一个人没有苦难的感受，就不容易对他人给予同情。你要学救苦救难的精神，就得先受苦受难。</p>
<p>　　65.世界原本就不是属于你，因此你用不着抛弃，要抛弃的是一切的执著。万物皆为我所用，但非我所属。</p>
<p>　　66.虽然我们不能改变周遭的世界，我们就只好改变自己，用慈悲心和智慧心来面对这一切。</p>
]]></content:encoded>
			<wfw:commentRss>http://qinshuwei.com/%e8%bd%ac%ef%bc%9a%e4%b8%ad%e5%9b%bd%e4%bd%9b%e5%ad%a666%e5%8f%a5%e9%9c%87%e6%92%bc%e4%b8%96%e7%95%8c%e7%9a%84%e7%a6%85%e8%af%ad.html/feed</wfw:commentRss>
		<slash:comments>118</slash:comments>
		</item>
		<item>
		<title>HttpClient4.0对cookie的操作</title>
		<link>http://qinshuwei.com/httpclient-cookie.html</link>
		<comments>http://qinshuwei.com/httpclient-cookie.html#comments</comments>
		<pubDate>Sun, 21 Mar 2010 13:31:23 +0000</pubDate>
		<dc:creator>Myonlystar</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://qinshuwei.com/?p=1599</guid>
		<description><![CDATA[
手机WAP中间件项目中一直存在一个问题是：如何使用虚拟浏览器模拟成多个客户端对网站进行操作。尤其是，面对需要用户登录才能访问的网站，虚拟浏览器如何能在用户第一次登录后，记住不同用户的cookie,进行后续取得权限的模拟操作，而不会每次操作都要登录并保证用户访问自己的页面。
还好通过google的帮助，发现Apache下的开源项目HttpClient可以很好的解决这个问题。周末学习了两天，并结合项目需求，自己动手写了个小实例。解决了虚拟浏览器中模拟form表单请求和抓取用户登陆后sendRedirect页面内容以及保存cookie三个问题。关于如何模拟成多个浏览器进行登录，我现在初步打算为：保存每一个手机端登录的cookie，然后当手机端再次调用虚拟浏览器时，能够取出cookie封装到HttpClient实例中进行提交。不罗嗦，下面是实例的代码：


?Download ClientOperate.java1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package ouc.sei.common;
&#160;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
&#160;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.cookie.Cookie;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HTTP;
&#160;
import com.sun.net.httpserver.HttpContext;
&#160;
/**
 * 类封装了虚拟浏览器的一些基本操作
 * @author qsw-Myonlystar
 * 
 */
public class ClientOperate &#123;
&#160;
	/**
	 * 处理一个实体
	 * 
	 * @param entity
	 */
	public StringBuffer processEntity&#40;HttpEntity entity,String encodType&#41; &#123;
		StringBuffer sb [...]]]></description>
			<content:encoded><![CDATA[<div style="border-left: 5px solid rgb(221, 221, 221); margin: 15px 30px 0pt 10px; padding-left: 20px;">
手机WAP中间件项目中一直存在一个问题是：如何使用虚拟浏览器模拟成多个客户端对网站进行操作。尤其是，面对需要用户登录才能访问的网站，虚拟浏览器如何能在用户第一次登录后，记住不同用户的cookie,进行后续取得权限的模拟操作，而不会每次操作都要登录并保证用户访问自己的页面。<br/><br/><br />
还好通过google的帮助，发现Apache下的开源项目HttpClient可以很好的解决这个问题。周末学习了两天，并结合项目需求，自己动手写了个小实例。解决了<font color="#ff0000"><strong>虚拟浏览器中模拟form表单请求</strong></font>和<font color="#ff0000"><strong>抓取用户登陆后sendRedirect页面内容</strong></font>以及<font color="#ff0000"><strong>保存cookie</strong></font>三个问题。关于如何模拟成多个浏览器进行登录，我现在初步打算为：<font color="#ff0000"><strong>保存每一个手机端登录的cookie，然后当手机端再次调用虚拟浏览器时，能够取出cookie封装到HttpClient实例中进行提交。</strong></font>不罗嗦，下面是实例的代码：<br/><br/></p>
<div style="border-left: 5px solid rgb(221, 221, 221); margin: 15px 30px 0pt 10px; padding-left: 20px;">

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://qinshuwei.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=1599&amp;download=ClientOperate.java">ClientOperate.java</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p159913"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
</pre></td><td class="code" id="p1599code13"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">ouc.sei.common</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.BufferedReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStreamReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.Header</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.HttpEntity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.HttpResponse</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.HttpStatus</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.NameValuePair</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.CookieStore</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.HttpClient</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.entity.UrlEncodedFormEntity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.HttpGet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.HttpPost</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.params.CookiePolicy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.params.HttpClientParams</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.protocol.ClientContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.cookie.Cookie</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.entity.StringEntity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.impl.client.AbstractHttpClient</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.impl.client.DefaultHttpClient</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.message.BasicNameValuePair</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.protocol.BasicHttpContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.protocol.HTTP</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.net.httpserver.HttpContext</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 类封装了虚拟浏览器的一些基本操作
 * @author qsw-Myonlystar
 * 
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ClientOperate <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * 处理一个实体
	 * 
	 * @param entity
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astringbuffer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">StringBuffer</span></a> processEntity<span style="color: #009900;">&#40;</span>HttpEntity entity,<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> encodType<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astringbuffer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">StringBuffer</span></a> sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astringbuffer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">StringBuffer</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstreamreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InputStreamReader</span></a> iReader <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;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// 从消息实体中获取输入流对象</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InputStream</span></a> inputStream <span style="color: #339933;">=</span> entity.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			iReader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstreamreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InputStreamReader</span></a><span style="color: #009900;">&#40;</span>inputStream,encodType<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedReader</span></a> reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedReader</span></a><span style="color: #009900;">&#40;</span>iReader<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> line <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// 用reader.ready()是不行的，这是用来判断此流是否已准备好被读取</span>
			<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">=</span> reader.<span style="color: #006633;">readLine</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: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&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> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ex.<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: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
				iReader.<span style="color: #006633;">close</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: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> 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: #000000; font-weight: bold;">return</span> sb<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * 判断服务器页面是否重定向
	 * 
	 * @param statuscode
	 *            response中的状态码
	 * @return
	 */</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;">boolean</span> ifRedirect<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> statusCode<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">boolean</span> flag <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>statusCode <span style="color: #339933;">==</span> HttpStatus.<span style="color: #006633;">SC_MOVED_PERMANENTLY</span><span style="color: #009900;">&#41;</span>
				<span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>statusCode <span style="color: #339933;">==</span> HttpStatus.<span style="color: #006633;">SC_MOVED_TEMPORARILY</span><span style="color: #009900;">&#41;</span>
				<span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>statusCode <span style="color: #339933;">==</span> HttpStatus.<span style="color: #006633;">SC_SEE_OTHER</span><span style="color: #009900;">&#41;</span>
				<span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>statusCode <span style="color: #339933;">==</span> HttpStatus.<span style="color: #006633;">SC_TEMPORARY_REDIRECT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			flag <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> flag<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * 打印服务器返回的状态
	 * @param response
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> printResponseStatus<span style="color: #009900;">&#40;</span>HttpResponse response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-----------服务器返回状态------------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">getStatusLine</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: #666666; font-style: italic;">// 服务器返回状态</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><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: #008000; font-style: italic; font-weight: bold;">/**
	 * 打印返回的头部信息
	 * @param response
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> printAllHeaders<span style="color: #009900;">&#40;</span>HttpResponse response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-----------返回的HTTP头信息------------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Header<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> headers <span style="color: #339933;">=</span> response.<span style="color: #006633;">getAllHeaders</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;">// 返回的HTTP头信息</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;">&lt;</span> headers.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>headers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-------------返回的HTTP头信息----------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span>
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * 打印cookie信息
	 * @param httpclient
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> printCookie<span style="color: #009900;">&#40;</span>DefaultHttpClient httpclient<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Initial set of cookies:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
	        List<span style="color: #339933;">&lt;</span>Cookie<span style="color: #339933;">&gt;</span> cookies <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">getCookieStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getCookies</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;">if</span> <span style="color: #009900;">&#40;</span>cookies.<span style="color: #006633;">isEmpty</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>  
	            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;None&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;">else</span> <span style="color: #009900;">&#123;</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;">&lt;</span> cookies.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
	                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;- &quot;</span> <span style="color: #339933;">+</span> cookies.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</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: #009900;">&#125;</span>  
	        <span style="color: #009900;">&#125;</span> 
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<div style="border-left: 5px solid rgb(221, 221, 221); margin: 15px 30px 0pt 10px; padding-left: 20px;">

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://qinshuwei.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=1599&amp;download=Test.java">Test.java</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p159914"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
</pre></td><td class="code" id="p1599code14"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">ouc.sei.common</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.HttpEntity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.HttpResponse</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.NameValuePair</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.CookieStore</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.entity.UrlEncodedFormEntity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.HttpGet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.HttpPost</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.params.CookiePolicy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.params.HttpClientParams</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.protocol.ClientContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.impl.client.DefaultHttpClient</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.message.BasicNameValuePair</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.protocol.BasicHttpContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.protocol.HTTP</span><span style="color: #339933;">;</span>
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 类作用是测试虚拟浏览器保存cookie值，并抓取跳转后的页面源码。
 * @author qsw-Myonlystar 
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Test <span style="color: #009900;">&#123;</span>
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * @param args
	 * @throws Exception
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</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><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><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> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
		HttpGet httpget <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		CookieStore cookieStore<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		ClientOperate oper<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> ClientOperate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		DefaultHttpClient httpclient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// 设置cookie的兼容性，这一行必须要加，否则服务器无法获取登陆状态</span>
		HttpClientParams.<span style="color: #006633;">setCookiePolicy</span><span style="color: #009900;">&#40;</span>httpclient.<span style="color: #006633;">getParams</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				CookiePolicy.<span style="color: #006633;">BROWSER_COMPATIBILITY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		HttpPost httpost <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://222.195.150.224:8080/SEI/login.jsp&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		<span style="color: #666666; font-style: italic;">// 设置参数的集合</span>
		List<span style="color: #339933;">&lt;</span>NameValuePair<span style="color: #339933;">&gt;</span> nvps <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>NameValuePair<span style="color: #339933;">&gt;</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;">// 设置参数，格式是name:value</span>
		nvps.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> BasicNameValuePair<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;username&quot;</span>, <span style="color: #0000ff;">&quot;kelly&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		nvps.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> BasicNameValuePair<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;password&quot;</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: #666666; font-style: italic;">// 对参数实体进行格式转换</span>
		UrlEncodedFormEntity urlEntity <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UrlEncodedFormEntity<span style="color: #009900;">&#40;</span>nvps,
				HTTP.<span style="color: #006633;">UTF_8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// 设置实体</span>
		httpost.<span style="color: #006633;">setEntity</span><span style="color: #009900;">&#40;</span>urlEntity<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		HttpResponse response <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpost<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//获取cookie</span>
		cookieStore<span style="color: #339933;">=</span>httpclient.<span style="color: #006633;">getCookieStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		BasicHttpContext localContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BasicHttpContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		localContext.<span style="color: #006633;">setAttribute</span><span style="color: #009900;">&#40;</span>ClientContext.<span style="color: #006633;">COOKIE_STORE</span>, cookieStore<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//httpost.abort();</span>
		oper.<span style="color: #006633;">printAllHeaders</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		oper.<span style="color: #006633;">printCookie</span><span style="color: #009900;">&#40;</span>httpclient<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		oper.<span style="color: #006633;">printResponseStatus</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// httpclient = new DefaultHttpClient();</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> newUrl <span style="color: #339933;">=</span> response.<span style="color: #006633;">getLastHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;转向的页面是：&quot;</span><span style="color: #339933;">+</span>newUrl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		httpclient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		httpget <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet<span style="color: #009900;">&#40;</span>newUrl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		HttpResponse responses <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpget,localContext<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// 从响应中获取消息实体，如果有的话</span>
		HttpEntity entity <span style="color: #339933;">=</span> responses.<span style="color: #006633;">getEntity</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;">// 处理消息实体中的内容</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astringbuffer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">StringBuffer</span></a> sb <span style="color: #339933;">=</span> oper.<span style="color: #006633;">processEntity</span><span style="color: #009900;">&#40;</span>entity,<span style="color: #0000ff;">&quot;gbk&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>sb<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><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aruntimeexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">RuntimeException</span></a> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// 终止执行请求</span>
			httpost.<span style="color: #006633;">abort</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> ex<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #666666; font-style: italic;">// 释放连接</span>
		httpclient.<span style="color: #006633;">getConnectionManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">shutdown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<p>我使用的http版本是4.0，还需要引用的jar包为：<font color="#ff0000"><strong>commons-codec-1.4.jar commons-logging-1.1.1.jar httpcore-4.0.1.jar httpmime-4.0.1.jar。</strong></font><br/><br/><br />
PS:我今天终于知道了原来做一个外挂这么简单。<br/><br/></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://qinshuwei.com/httpclient-cookie.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何去除html代码中标签的属性</title>
		<link>http://qinshuwei.com/regex.html</link>
		<comments>http://qinshuwei.com/regex.html#comments</comments>
		<pubDate>Wed, 10 Mar 2010 12:55:57 +0000</pubDate>
		<dc:creator>Myonlystar</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://qinshuwei.com/?p=1588</guid>
		<description><![CDATA[项目的需要，正则表达式可以完成，只需要将]*>替换为就可以了。
]]></description>
			<content:encoded><![CDATA[<p>项目的需要，正则表达式可以完成，只需要将<font color="#ff0000"><strong><(\w*)\s[^>]*></strong></font>替换为<font color="#ff0000"><strong><$1></strong></font>就可以了。</p>
]]></content:encoded>
			<wfw:commentRss>http://qinshuwei.com/regex.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>随笔</title>
		<link>http://qinshuwei.com/%e9%9a%8f%e7%ac%94.html</link>
		<comments>http://qinshuwei.com/%e9%9a%8f%e7%ac%94.html#comments</comments>
		<pubDate>Tue, 02 Mar 2010 13:39:10 +0000</pubDate>
		<dc:creator>Myonlystar</dc:creator>
				<category><![CDATA[心情随笔]]></category>
		<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://qinshuwei.com/?p=1585</guid>
		<description><![CDATA[好久没来自己的博客上踩踩了，晚上看着论文，脑子一片空白，上这里来活动活动筋骨吧。。。。
貌似放假已经是去年的事情了，从回家开始，嘴上就开始溃疡，起泡，断断续续的，一直到今天。痛，死不了人，但是刷牙、吃饭、喝水，都让你痛不欲生。妈说：小小年纪，你怎么那么大的火气。我只好笑笑：妈，我回家水土不服。。。。。
晚上，哥跟我发短信说，烟台下从十五开始下大雪了，一直到今天，厚厚的，下午推了60多车的雪才把院子里的雪清干净，整个村子很壮观，你又错过了。是啊，好像烟台很不喜欢让我看到它下雪的一面：回家前，铺天盖地，盼着到放假了，却晴空万里，刚溜脚回来，屁股还没坐热，就又按部就班下起了大雪。害的我只能流着口水干着急。。。
回来快一个周了，也没做什么，除了看论文，剩下的时间就是跟yy在一起，人很多时候都是习惯了，习惯了分开了就很不习惯，回来后一起一天看完了一部电视剧，算是小小的放纵了一下自己，也是新年的一起小小庆祝一下。年前yy送我一个日历，上学期太放纵自己了，这学期好好监督自己。论文、开题、项目每一样都不能松懈。
看了一天的论文，头有点大。英语句子半天没憋出一句来。杨哥跟我们说，写论文直接写英文的，不用中文，还影响思路。看来对我难度不小。算了吧，还是先写出一份中文的草案来理理思路吧，这样至少给杨哥、Mr Jia看的时候，别人也知道自己在说啥。。。。。
犯困了，不写了，明天继续论文吧。。。。。。
]]></description>
			<content:encoded><![CDATA[<p>好久没来自己的博客上踩踩了，晚上看着论文，脑子一片空白，上这里来活动活动筋骨吧。。。。<br />
貌似放假已经是去年的事情了，从回家开始，嘴上就开始溃疡，起泡，断断续续的，一直到今天。痛，死不了人，但是刷牙、吃饭、喝水，都让你痛不欲生。妈说：小小年纪，你怎么那么大的火气。我只好笑笑：妈，我回家水土不服。。。。。<br />
晚上，哥跟我发短信说，烟台下从十五开始下大雪了，一直到今天，厚厚的，下午推了60多车的雪才把院子里的雪清干净，整个村子很壮观，你又错过了。是啊，好像烟台很不喜欢让我看到它下雪的一面：回家前，铺天盖地，盼着到放假了，却晴空万里，刚溜脚回来，屁股还没坐热，就又按部就班下起了大雪。害的我只能流着口水干着急。。。<br />
回来快一个周了，也没做什么，除了看论文，剩下的时间就是跟yy在一起，人很多时候都是习惯了，习惯了分开了就很不习惯，回来后一起一天看完了一部电视剧，算是小小的放纵了一下自己，也是新年的一起小小庆祝一下。年前yy送我一个日历，上学期太放纵自己了，这学期好好监督自己。论文、开题、项目每一样都不能松懈。<br />
看了一天的论文，头有点大。英语句子半天没憋出一句来。杨哥跟我们说，写论文直接写英文的，不用中文，还影响思路。看来对我难度不小。算了吧，还是先写出一份中文的草案来理理思路吧，这样至少给杨哥、Mr Jia看的时候，别人也知道自己在说啥。。。。。<br />
犯困了，不写了，明天继续论文吧。。。。。。</p>
]]></content:encoded>
			<wfw:commentRss>http://qinshuwei.com/%e9%9a%8f%e7%ac%94.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
