﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-swordinheart</title><link>http://www.blogjava.net/swordinheart/</link><description /><language>zh-cn</language><lastBuildDate>Wed, 29 Apr 2026 21:31:53 GMT</lastBuildDate><pubDate>Wed, 29 Apr 2026 21:31:53 GMT</pubDate><ttl>60</ttl><item><title>junipor考试心得</title><link>http://www.blogjava.net/swordinheart/archive/2010/08/31/330345.html</link><dc:creator>飞刀和雨</dc:creator><author>飞刀和雨</author><pubDate>Mon, 30 Aug 2010 17:10:00 GMT</pubDate><guid>http://www.blogjava.net/swordinheart/archive/2010/08/31/330345.html</guid><wfw:comment>http://www.blogjava.net/swordinheart/comments/330345.html</wfw:comment><comments>http://www.blogjava.net/swordinheart/archive/2010/08/31/330345.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/swordinheart/comments/commentRss/330345.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/swordinheart/services/trackbacks/330345.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;今天终于考完junipor的免费大餐，一共5门，虽然不是非常的难，但也耗费了不少时间。总结一下，JNO-100别看是最低级的，由于其分数线要非常高，要85分，所以这门是最难的一门，很多人也是载在这门课程上的，过了这门，后面的jno-331,400为80分及格就显的简单多了，至于jno342,350的及格线为70分加上前面的熟读题目基本就是轻松过关了。<br />
&nbsp;&nbsp;&nbsp;&nbsp; 哪位兄弟也想考该类认证，我可以分享考试用的题库。但由于不知道如何上传。留email吧
<img src ="http://www.blogjava.net/swordinheart/aggbug/330345.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/swordinheart/" target="_blank">飞刀和雨</a> 2010-08-31 01:10 <a href="http://www.blogjava.net/swordinheart/archive/2010/08/31/330345.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ruby和Java之间的比较(一) (飞刀和雨)</title><link>http://www.blogjava.net/swordinheart/archive/2007/05/17/118100.html</link><dc:creator>飞刀和雨</dc:creator><author>飞刀和雨</author><pubDate>Thu, 17 May 2007 07:18:00 GMT</pubDate><guid>http://www.blogjava.net/swordinheart/archive/2007/05/17/118100.html</guid><wfw:comment>http://www.blogjava.net/swordinheart/comments/118100.html</wfw:comment><comments>http://www.blogjava.net/swordinheart/archive/2007/05/17/118100.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/swordinheart/comments/commentRss/118100.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/swordinheart/services/trackbacks/118100.html</trackback:ping><description><![CDATA[&nbsp;
<p align=center><span>Ruby</span><span>和</span><span>Java</span><span>之间的比较</span></p>
<p align=center><span>（飞刀和雨）</span></p>
<p><span><span>1．&nbsp;</span></span><span>基本类型的比较</span><span>Ruby</span><span>的基本数据类型</span></p>
<p><img style="WIDTH: 907px; HEIGHT: 662px" height=662 alt="" src="http://www.blogjava.net/images/blogjava_net/swordinheart/ruby_basic_datatype.JPG" width=907 border=0></p>
<p><strong><span>1</span></strong><strong><span>数值型</span><span>(numeric)</span></strong></p>
<p><strong><span>Java</span></strong><strong><span>拥有</span><span>8</span></strong><strong><span>种主治类型</span><span>, Boolean,byte,char.short,int,long,float,double.</span></strong><strong><span>在开发中我们往往只常用到</span><span>boolean, char, int &amp; double</span></strong><strong><span>。</span><span>&nbsp;</span></strong></p>
<p><strong><span>Ruby</span></strong><strong><span>则巧妙的使用了</span><span>2</span></strong><strong><span>类</span><span> Fixnum</span></strong><strong><span>和</span><span>Bignum</span></strong><strong><span>，而且</span><span>ruby</span></strong><strong><span>不需要你去定义这个数字类型，只需你输入个数，</span><span>ruby</span></strong><strong><span>会自动地进行必须的转换。用户不必担心数字之间的差别</span></strong></p>
<p><strong>&nbsp;</strong></p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=103>
            <p><strong>&nbsp;</strong></p>
            </td>
            <td vAlign=top width=120>
            <p><strong><span>ruby</span></strong></p>
            </td>
            <td vAlign=top width=345>
            <p><strong><span>Java</span></strong></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=103>
            <p><strong><span>字符串转数字</span></strong></p>
            </td>
            <td vAlign=top width=120>
            <p><strong><span>N = &#8216;<st1:chmetcnv UnitName="&#8217;" SourceValue="400" HasSpace="False" Negative="False" NumberType="1" TCSC="0" w:st="on">400&#8217;</st1:chmetcnv>.to_i</span></strong></p>
            </td>
            <td vAlign=top width=345>
            <p><strong><span>N= new Integer(&#8220;<st1:chmetcnv UnitName="&#8221;" SourceValue="400" HasSpace="False" Negative="False" NumberType="1" TCSC="0" w:st="on">400&#8221;</st1:chmetcnv>).intValue( );</span></strong></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=103>
            <p><strong><span>随机数</span></strong></p>
            </td>
            <td vAlign=top width=120>
            <p><strong><span>A = rand(5)</span></strong></p>
            </td>
            <td vAlign=top width=345>
            <p><strong><span>Random random = new java,util.Random();</span></strong></p>
            <p><strong><span>&nbsp;int A = random.nextInt(5); </span></strong></p>
            </td>
        </tr>
    </tbody>
</table>
<p><strong>&nbsp;</strong></p>
<p><strong><span>Ruby</span></strong><strong><span>提供良好的数学运算公式，这些是</span><span>java.math </span></strong><strong><span>所不能够比拟的</span></strong></p>
<p><strong><span>1. </span></strong><strong><span>对数的使用：</span><span>Math.loh(1)<span>&nbsp;&nbsp;&nbsp; </span>Math.log10(1000)</span></strong></p>
<p><strong><span>2. </span></strong><strong><span>求矩阵算法，求解线形的方程组，复数的使用</span></strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong><span><span>2．<span> </span></span></span></strong><strong><span>字符串类型（</span><span>String</span></strong><strong><span>）</span></strong></p>
<p><strong><span>Java</span></strong><strong><span>中处理字符串一般都是使用</span><span>String</span></strong><strong><span>类或者</span><span>StringBuffer</span></strong><strong><span>类，而</span><span>ruby</span></strong><strong><span>的使用则更加的方便和快速。</span><span>Ruby</span></strong><strong><span>的字符串的大小是可变的。可以无需使用更多的时间和内存。</span></strong></p>
<p><strong>&nbsp;</strong></p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=115>
            <p><strong>&nbsp;</strong></p>
            </td>
            <td vAlign=top width=108>
            <p><strong><span>ruby</span></strong></p>
            </td>
            <td vAlign=top width=345>
            <p><strong><span>Java</span></strong></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=115>
            <p><strong><span>打印时变量带入字符串</span></strong></p>
            </td>
            <td vAlign=top width=108>
            <p><strong><span>Puts &#8220;This is #{number}&#8221;</span></strong></p>
            </td>
            <td vAlign=top width=345>
            <p><strong><span>System.out.println(&#8220;This is &#8221;+number);</span></strong></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=115>
            <p><strong><span>字符与值转换</span></strong></p>
            </td>
            <td vAlign=top width=108>
            <p><strong><span>?a&nbsp;</span></strong><strong><span><span>&#232;</span></span><span>97</span></strong></p>
            </td>
            <td vAlign=top width=345>
            <p><strong><span>int x = (int)&#8217;a&#8217;;</span></strong></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=115>
            <p><strong><span>大小写转换</span></strong></p>
            </td>
            <td vAlign=top width=108>
            <p><strong><span>s,downcase</span></strong></p>
            </td>
            <td vAlign=top width=345>
            <p><strong><span>s.lowerCase();</span></strong></p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=115>
            <p><strong><span>或得字符串部分</span></strong></p>
            </td>
            <td vAlign=top width=108>
            <p><strong><span>s[3.5]</span></strong></p>
            </td>
            <td vAlign=top width=345>
            <p><strong><span>s.indexOf(3,5);</span></strong></p>
            </td>
        </tr>
    </tbody>
</table>
<p><strong>&nbsp;</strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong><span><span>3．<span> </span></span></span></strong><strong><span>范围类型。</span></strong></p>
<p><strong><span>这类的文件是</span><span>java</span></strong><strong><span>所没有的，所以对于很多开发人员来说这是一个很新的类型，</span></strong></p>
<p><strong><span>代表了一个系列的值，当然</span></strong></p>
<p><strong><span>使用</span><span>s..e</span></strong><strong><span>和</span><span>s&#8230;e</span></strong><strong><span>。后面的一个不包括最后一个值</span></strong></p>
<p><strong><span>(-1..-5).to_a</span></strong></p>
<img src ="http://www.blogjava.net/swordinheart/aggbug/118100.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/swordinheart/" target="_blank">飞刀和雨</a> 2007-05-17 15:18 <a href="http://www.blogjava.net/swordinheart/archive/2007/05/17/118100.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>对Cocoon的认识和初步理解(飞刀和雨)</title><link>http://www.blogjava.net/swordinheart/archive/2006/08/18/64348.html</link><dc:creator>飞刀和雨</dc:creator><author>飞刀和雨</author><pubDate>Fri, 18 Aug 2006 07:00:00 GMT</pubDate><guid>http://www.blogjava.net/swordinheart/archive/2006/08/18/64348.html</guid><wfw:comment>http://www.blogjava.net/swordinheart/comments/64348.html</wfw:comment><comments>http://www.blogjava.net/swordinheart/archive/2006/08/18/64348.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/swordinheart/comments/commentRss/64348.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/swordinheart/services/trackbacks/64348.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 对														Cocoon														的认识和初步理解(飞刀和雨)：																																																																						 																								目标	...&nbsp;&nbsp;<a href='http://www.blogjava.net/swordinheart/archive/2006/08/18/64348.html'>阅读全文</a><img src ="http://www.blogjava.net/swordinheart/aggbug/64348.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/swordinheart/" target="_blank">飞刀和雨</a> 2006-08-18 15:00 <a href="http://www.blogjava.net/swordinheart/archive/2006/08/18/64348.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于luncene 内层的研究（飞刀和雨）</title><link>http://www.blogjava.net/swordinheart/archive/2006/03/02/33327.html</link><dc:creator>飞刀和雨</dc:creator><author>飞刀和雨</author><pubDate>Thu, 02 Mar 2006 15:31:00 GMT</pubDate><guid>http://www.blogjava.net/swordinheart/archive/2006/03/02/33327.html</guid><wfw:comment>http://www.blogjava.net/swordinheart/comments/33327.html</wfw:comment><comments>http://www.blogjava.net/swordinheart/archive/2006/03/02/33327.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/swordinheart/comments/commentRss/33327.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/swordinheart/services/trackbacks/33327.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 关于luncene 内层的研究（飞刀和雨）&nbsp; 这是很久以前做lucene 时的总结，现在已经不用去研究那些代码，但还是分享出来给大家以帮助。谢谢1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 从Index开始无论哪种搜索引擎，都会需要自建一个index，所有的搜词准确率及快速性很大程度上取决于这类的问题。因此在建索引文件的时候，我们首先要弄清楚l...&nbsp;&nbsp;<a href='http://www.blogjava.net/swordinheart/archive/2006/03/02/33327.html'>阅读全文</a><img src ="http://www.blogjava.net/swordinheart/aggbug/33327.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/swordinheart/" target="_blank">飞刀和雨</a> 2006-03-02 23:31 <a href="http://www.blogjava.net/swordinheart/archive/2006/03/02/33327.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>图解安装 netgear WGR614 无线路由</title><link>http://www.blogjava.net/swordinheart/archive/2006/02/13/30476.html</link><dc:creator>飞刀和雨</dc:creator><author>飞刀和雨</author><pubDate>Mon, 13 Feb 2006 09:11:00 GMT</pubDate><guid>http://www.blogjava.net/swordinheart/archive/2006/02/13/30476.html</guid><wfw:comment>http://www.blogjava.net/swordinheart/comments/30476.html</wfw:comment><comments>http://www.blogjava.net/swordinheart/archive/2006/02/13/30476.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/swordinheart/comments/commentRss/30476.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/swordinheart/services/trackbacks/30476.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 周六买了个netgear路由，讨价还价310买下，谁知道里面的安装说明书不详细，弄了一晚上没弄出来，周日中午打车去换了个，半小时搞定，看来电脑城里次品还是蛮多的，希望大家买电脑的时候要测试好在买，否则来回出租车费加上，估计可以换个108M的了。装好后在网上闲逛时发现有关这款路由的安装指南，居然是doc形式，难怪搜索不容易找到，现在取其精华，给以后购买者点帮助，呵呵。第1步 将WGR614v...&nbsp;&nbsp;<a href='http://www.blogjava.net/swordinheart/archive/2006/02/13/30476.html'>阅读全文</a><img src ="http://www.blogjava.net/swordinheart/aggbug/30476.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/swordinheart/" target="_blank">飞刀和雨</a> 2006-02-13 17:11 <a href="http://www.blogjava.net/swordinheart/archive/2006/02/13/30476.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于Google的Suggest功能的实现(飞刀和雨)</title><link>http://www.blogjava.net/swordinheart/archive/2005/11/04/18164.html</link><dc:creator>飞刀和雨</dc:creator><author>飞刀和雨</author><pubDate>Fri, 04 Nov 2005 08:45:00 GMT</pubDate><guid>http://www.blogjava.net/swordinheart/archive/2005/11/04/18164.html</guid><wfw:comment>http://www.blogjava.net/swordinheart/comments/18164.html</wfw:comment><comments>http://www.blogjava.net/swordinheart/archive/2005/11/04/18164.html#Feedback</comments><slash:comments>29</slash:comments><wfw:commentRss>http://www.blogjava.net/swordinheart/comments/commentRss/18164.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/swordinheart/services/trackbacks/18164.html</trackback:ping><description><![CDATA[<H1 style="MARGIN: 17pt 0cm 16.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">关于</SPAN><SPAN lang=EN-US>Google</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>Suggest</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">功能的实现</SPAN></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>@@@</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">使用</SPAN><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US>Ajax</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">及</SPAN><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US>Lucene</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对其进行完美实现</SPAN><SPAN lang=EN-US>@@@ (</SPAN><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">飞刀和雨</SPAN></B><SPAN lang=EN-US>)</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">大家都对</SPAN><SPAN lang=EN-US>Google</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>suggest</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的功能大概很有兴趣吧，我们觉得既然</SPAN><SPAN lang=EN-US>Google</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">做的出，那么我们也能做出来，先对其进行分析，</SPAN><SPAN lang=EN-US>1.</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对于网页客户端的按键的动态变化，</SPAN><SPAN lang=EN-US>Ajax</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是最好的选择，</SPAN> <SPAN lang=EN-US><?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 414.75pt; HEIGHT: 255.75pt" type="#_x0000_t75"><v:imagedata o:title="google_suggest" src="file:///C:\DOCUME~1\wanwgenz\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg"><IMG height=401 alt=google_suggest.JPG src="http://www.blogjava.net/images/blogjava_net/swordinheart/google_suggest.JPG" width=651 border=0></v:imagedata></v:shape></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>2.</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果数据库的选择，则可以有多种选择得，</SPAN><SPAN lang=EN-US>BerkeleyDB, Derby</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">甚至自己做个</SPAN><SPAN lang=EN-US>txt</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文本文件，把所需要的单词和</SPAN><SPAN lang=EN-US>result</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数目放在文本文件里都能够实现，但今天我们有了一个很好的索引工具</SPAN><SPAN lang=EN-US>Lucene</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。加上</SPAN><SPAN lang=EN-US>Lucene</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对我的吸引力，因此今天我们用上大炮，卸去鸟枪。开始我们的开发之路。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">首先，我们先建立个</SPAN><SPAN lang=EN-US>demo</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的框架，我就做了个这样的一个</SPAN><SPAN lang=EN-US>html</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件，用了一个</SPAN><SPAN lang=EN-US>form,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一个</SPAN><SPAN lang=EN-US><v:shape id=_x0000_i1026 style="WIDTH: 422.25pt; HEIGHT: 60.75pt" type="#_x0000_t75"><IMG height=75 alt=search_suggest.JPG src="http://www.blogjava.net/images/blogjava_net/swordinheart/search_suggest.JPG" width=533 border=0>&nbsp;<v:imagedata o:title="demo_suggest" src="file:///C:\DOCUME~1\wanwgenz\LOCALS~1\Temp\msohtml1\01\clip_image003.jpg"></v:imagedata></v:shape></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">输入的文本框，一个多选项和一个确认按键。后面两个没什么好说的，主要是文本框的设计，我做了以下的定义，</SPAN><SPAN lang=EN-US>&lt;input<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>type="text" size=60 id="userid" name="q" autocomplete="off" onKeyUp="validate(event);"&gt;</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">　这样</SPAN><SPAN lang=EN-US>autocomplete</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">＝</SPAN><SPAN lang=EN-US>off</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">指取消网页的</SPAN><SPAN lang=EN-US>cache</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，这样就不会弹出以前打过的字的窗口，造成混乱。</SPAN><SPAN lang=EN-US>onKeyUp</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是实现</SPAN><SPAN lang=EN-US>ajax</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的关键，相应键盘输入的操作。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其次，开始我们的</SPAN><SPAN lang=EN-US>Ajax</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">了，顾名思义，</SPAN><SPAN lang=EN-US>Ajax</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">指异步的</SPAN><SPAN lang=EN-US>javascript</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN-US>xml. </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我们的所有工作都会在</SPAN><SPAN lang=EN-US>javascript</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中完成，至于</SPAN><SPAN lang=EN-US>ajax</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">原理，很多地方都有很详细的解释，这里就指列应用了。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 15.75pt; TEXT-INDENT: -15.75pt; mso-char-indent-count: -1.5"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">　</SPAN><SPAN lang=EN-US>validate(e){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>var key=e.KeyCode;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">获得输入的键值</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-char-indent-count: -2.0"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">　　</SPAN><SPAN lang=EN-US>//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">定义按键只对字母数字，空格，回车，</SPAN><SPAN lang=EN-US>Ins</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN-US>del</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有效，可以避免一些无效的相应，并</SPAN><SPAN lang=EN-US>//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">转发</SPAN><SPAN lang=EN-US>url</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">给</SPAN><SPAN lang=EN-US>servlet,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">那么我们只要等</SPAN><SPAN lang=EN-US>servlet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回</SPAN><SPAN lang=EN-US>xml</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就可以了</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">　　</SPAN><SPAN lang=EN-US>if (key&gt;=48 &amp;&amp; key&lt;=90 || key==8 || key==32 || key== 45 || key==46){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">　　　</SPAN><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>var url = "LuceneSearch?id=" + encodeURI(idField.value);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>req.open("GET", url, true);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>req.onreadystatechange = processRequest;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>req.send(null);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这时，可以通过</SPAN><SPAN lang=EN-US>Ajax</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>3</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个</SPAN><SPAN lang=EN-US>req</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的请求进行向服务器发送，我们这里只要等待服务器返回的</SPAN><SPAN lang=EN-US>xml</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就可以了。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>function processRequest(){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>if(req.readyState==4){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>if(req.status==200){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>parseMessages();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}else{</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>clearTable();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这里我们通过返回的状态</SPAN><SPAN lang=EN-US>, </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">得到一个</SPAN><SPAN lang=EN-US>XmlHttp</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>readyState=4</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">表示</SPAN><SPAN lang=EN-US>servlet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的操作结束，</SPAN><SPAN lang=EN-US>status</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>=200</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">则表示</SPAN><SPAN lang=EN-US>Http</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">得到正常的返回，这时调用</SPAN><SPAN lang=EN-US>parseMessage()</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就可以对所得到的</SPAN><SPAN lang=EN-US>XmlHttp</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行操作，</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>function parseMessages(){ </SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>var products = req.responseXML.getElementsByTagName("products")[0];</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>for (loop=0;loop&lt;products.childNodes.length);loop++){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>var product = products.childNodes[loop];</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>var productname = product.getElementsByTagName("pname")[0];</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>var productnumber = product.getElementsByTagName("pnumber")[0];</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这里我们就在</SPAN><SPAN lang=EN-US>javascipt</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里就得到了我们所需要的词的</SPAN><SPAN lang=EN-US>name</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN-US>number,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后就只要在</SPAN><SPAN lang=EN-US>javascript</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里填入一些特效，便能很方便的实现</SPAN><SPAN lang=EN-US>Google</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>suggest.</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其次，我们所需要的就事编写我们现在的</SPAN><SPAN lang=EN-US>LuceneSearch</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>servlet. </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这里因为通过</SPAN><SPAN lang=EN-US>get</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方式传递，这不对于开发</SPAN><SPAN lang=EN-US>j2ee</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的程序员来说，就是小菜一碟，我们只要定义</SPAN><SPAN lang=EN-US>doGet(req, res)</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就能可以了实现了。从这里我们得到了</SPAN><SPAN lang=EN-US>Text</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文本框里的字符串值。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>public class LuceneSearch extends HttpServlet{</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>public<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>void doGet(HttpServletRequest request, HttpServletResponse<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>response)</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>throws IOException, ServletException {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>String targetId = request.getParameter("id");</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后我们需要对这些字符串进行清理，去掉些无效的符号，然后把多余空格合并，成为一种真正的需要的字符串，然后我们需要用</SPAN><SPAN lang=EN-US>Lucene</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来进行搜索，先把</SPAN><SPAN lang=EN-US>Document</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">把数据从数据库里读出来，然后制成</SPAN><SPAN lang=EN-US>Index</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。然后用</SPAN><SPAN lang=EN-US>Search</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来进行搜索，这里</SPAN><SPAN lang=EN-US>Lucene</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提供了很好的搜索方式，搜索分两种方式，一种是单个单词，这个就比较好办，</SPAN><SPAN lang=EN-US>Lucene </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提供了开头匹配的方法</SPAN><SPAN lang=EN-US>PrefixQuery(), </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">直接套用就可以了</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>PrefixQuery query = new PrefixQuery(new Term("keyword", targetId));</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>IndexSearcher searcher = new IndexSearcher(directory);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Hits hits = searcher.search(query,sort);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>for(int i=0; i&lt;hits.length();i++){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sb.append("&lt;product&gt;");</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sb.append("&lt;pname&gt;"+hits.doc(i).get("keyword")+"&lt;/pname&gt;");</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sb.append("&lt;pnumber&gt;"+hits.doc(i).get("number")+"&lt;/pnumber&gt;");</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sb.append("&lt;/product&gt;");</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这样我们就把搜索到的词和数量都放进</SPAN><SPAN lang=EN-US>Xml</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里了这样就出来了。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><v:shape id=_x0000_i1027 style="WIDTH: 393.75pt; HEIGHT: 189.75pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:\DOCUME~1\wanwgenz\LOCALS~1\Temp\msohtml1\01\clip_image005.png"><IMG height=264 alt=search_demo1.JPG src="http://www.blogjava.net/images/blogjava_net/swordinheart/search_demo1.JPG" width=536 border=0></v:imagedata></v:shape></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我们还可以注意到如果所需要的词并不在开头也能得到实现。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对于词组就比较费尽，因为首先要保证前面词的位置性，可以任意放置，最后一个词则必须以开头为基准进行模糊查找，这样才能实现其功能，还好</SPAN><SPAN lang=EN-US>Lucene</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">还是考虑到了这点，有个</SPAN><SPAN lang=EN-US>PhrasePrefixQuery()</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的方法，稍稍加以改进便可以实现，</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">首先要把词组用</SPAN><SPAN lang=EN-US>split</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">以空格分开</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>String[] targetIdArray = targetId.split(" ");</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>PhrasePrefixQuery query = new PhrasePrefixQuery();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>for(int i=0; i&lt;targetIdArray.length-1;i++){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>query.add(new Term("keyword",targetIdArray[i]));</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>query.setSlop(4); <SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设置词前后位置移动范围。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>LinkedList termsWithPrefix = new LinkedList();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>IndexReader ir = IndexReader.open(directory);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>TermEnum te = ir.terms(new Term("keyword", targetIdArray[targetIdArray.length-1]));</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>do {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>if (te.term().text().startsWith(targetIdArray[targetIdArray.length-1])) {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>termsWithPrefix.add(te.term());</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>} while (te.next());</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这样我们先得到最后一个单词为开头的词，然后加到</SPAN><SPAN lang=EN-US>PrasePrefixQuery</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>query.add((Term[])termsWithPrefix.toArray(new Term[0]));</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>Hits hits;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>hits = searcher.search(query, sort);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>for(int i=0; i&lt;(hits.length()&gt;20?20:hits.length());i++){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sb.append("&lt;product&gt;");</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sb.append("&lt;pname&gt;"+hits.doc(i).get("keyword")+"&lt;/pname&gt;");</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sb.append("&lt;pnumber&gt;"+hits.doc(i).get("popularity")+"&lt;/pnumber&gt;");</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sb.append("&lt;/product&gt;");</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这样我们就可以得到我们所需要的词组了。如图所示，很方便吧，这里就基本完成了</SPAN><SPAN lang=EN-US>google</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><v:shape id=_x0000_i1028 style="WIDTH: 399.75pt; HEIGHT: 206.25pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:\DOCUME~1\wanwgenz\LOCALS~1\Temp\msohtml1\01\clip_image007.png"><IMG height=263 alt=search_demo2.JPG src="http://www.blogjava.net/images/blogjava_net/swordinheart/search_demo2.JPG" width=527 border=0></v:imagedata></v:shape></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所代表的</SPAN><SPAN lang=EN-US>suggest</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">功能，当然，</SPAN><SPAN lang=EN-US>javascript</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里面还有一些上下键，鼠标移动事件的触发，加在一起就会把我们的网页弄得很完美了。但这些都不是重点，我们主要是对门户网站功能的实现，如果有问题和建议，可以给我留言，谢谢。</SPAN></P><img src ="http://www.blogjava.net/swordinheart/aggbug/18164.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/swordinheart/" target="_blank">飞刀和雨</a> 2005-11-04 16:45 <a href="http://www.blogjava.net/swordinheart/archive/2005/11/04/18164.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>