﻿<?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>IT博客-登陆不起啦(aiut) Thingking in B/S</title><link>http://www.cnitblog.com/aiut/</link><description /><language>zh-cn</language><lastBuildDate>Wed, 29 Apr 2026 05:58:36 GMT</lastBuildDate><pubDate>Wed, 29 Apr 2026 05:58:36 GMT</pubDate><ttl>60</ttl><item><title>关于Adodb.Stream 的使用说明</title><link>http://www.cnitblog.com/aiut/archive/2005/11/17/4643.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Thu, 17 Nov 2005 14:12:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/11/17/4643.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/4643.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/11/17/4643.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/4643.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/4643.html</trackback:ping><description><![CDATA[<TABLE class=showinfo style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellSpacing=0 cellPadding=3 width="100%" align=center border=0>
<TBODY>
<TR>
<TD class=showTitle align=middle>关于Adodb.Stream 的使用说明</TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 align=left border=0>
<TBODY>
<TR>
<TD>
<SCRIPT language=javascript src="/ad/js/edu_left_300-300.js"></SCRIPT>
</TD></TR></TBODY></TABLE>组件："Adodb.Stream" <BR><BR>有下列方法： <BR><BR><FONT color=#ff0000>Cancel 方法</FONT> <BR>使用方法如下 <BR>Object.Cancel <BR>说明：取消执行挂起的异步 Execute 或 Open 方法的调用。 <BR><BR><FONT color=#ff0000>Close 方法</FONT> <BR>使用方法如下 <BR>Object.Close <BR>：关闭对像 <BR><BR><FONT style="BACKGROUND-COLOR: #ffffff" color=#ff0000>CopyTo 方法</FONT> <BR>使用方法如下 <BR>Object.CopyTo(destStream,[CharNumber]) <BR>说明：将对像的数据复制，destStream指向要复制的对像，CharNumber为可选参数，指要复制的字节数，不选为全部复制。<BR>&nbsp;<BR><FONT color=#ff0000>Flush 方法</FONT> <BR>使用方法如下 <BR>Object.Flush <BR>说明： <BR><BR><FONT color=#ff0000>LoadFromFile 方法</FONT> <BR>使用方法如下 <BR>Object.LoadFromFile(FileName) <BR>说明:将FileName指定的文件装入对像中,参数FileName为指定的用户名。 <BR><BR><FONT color=#ff0000>Open 方法 <BR></FONT>使用方法如下 <BR>Object.Open(Source,[Mode],[Options],[UserName],[Password]) <BR>说明：打开对像， <BR>参数说明：Sourece 对像源，可不指定 <BR>Mode 指定打开模式，可不指定，可选参数如下： <BR>adModeRead =1 <BR>adModeReadWrite =3 <BR>adModeRecursive =4194304 <BR>adModeShareDenyNone =16 <BR>adModeShareDenyRead =4 <BR>adModeShareDenyWrite =8 <BR>adModeShareExclusive =12 <BR>adModeUnknown =0 <BR>adModeWrite =2 <BR>Options 指定打开的选项，可不指定，可选参数如下： <BR>adOpenStreamAsync =1 <BR>adOpenStreamFromRecord =4 <BR>adOpenStreamUnspecified=-1 <BR>UserName 指定用户名，可不指定。 <BR>Password 指定用户名的密码 <BR><BR><FONT color=#ff0000>Read 方法</FONT> <BR>使用方法如下： <BR>Object.Read(Numbytes) <BR>说明：读取指定长度的二进制内容。 <BR>参数说明：Numbytes指定的要读取的找度，不指定则读取全部。 <BR><BR><FONT color=#ff0000>ReadText 方法</FONT> <BR>使用方法如下： <BR>Object.ReadText(NumChars) <BR>说明：读取指定长度的文本 <BR>参数说明：NumChars指定的要读取的找度，不指定则读取全部。 <BR><BR><FONT color=#ff0000>SaveToFile 方法</FONT> <BR>使用方法如下： <BR>Object.SaveToFile(FileName,[Options]) <BR>说明：将对像的内容写到FileName指定的文件中 <BR>参数说明：FileName指定的文件 <BR>Options 存取的选项，可不指定，可选参数如下： <BR>adSaveCreateNotExist =1 <BR>adSaveCreateOverWrite =2 <BR><BR><FONT color=#ff0000>SetEOS 方法 <BR></FONT>使用方法如下： <BR>Object.setEOS() <BR>说明： <BR><BR><FONT color=#ff0000>SkipLine 方法 <BR></FONT>使用方法如下： <BR>Object.SkipLine() <BR>说明： <BR><BR><FONT color=#ff0000>Write 方法</FONT> <BR>使用方法如下： <BR>Object.Write(Buffer) <BR>说明：将指定的数据装入对像中。 <BR>参数说明：Buffer 为指定的要写入的内容。<BR>&nbsp;<BR><FONT color=#ff0000>WriteText 方法</FONT> <BR>使用方法如下： <BR>Object.Write(Data,[Options]) <BR>说明：将指定的文本数据装入对像中。 <BR>参数说明：Data 为指定的要写入的内容。 <BR>Options 写入的选项，可不指定，可选参数如下： <BR>adWriteChar =0 <BR>adWriteLine =1 <BR><BR><BR><BR><BR>有下列属性： <BR><FONT color=#ff0000>Charset</FONT> <BR>EOS 返回对像内数据是否为空。 <BR><BR><FONT color=#ff0000>LineSeparator</FONT> 指定换行格式，可选参数有 <BR>adCR =13 <BR>adCRLF =-1 <BR>adLF =10 <BR><BR><FONT color=#ff0000>Mode</FONT> 指定或返加模式。 <BR><BR><FONT color=#ff0000>Position</FONT> 指定或返加对像内数据的当前指针。 <BR><BR><FONT color=#ff0000>Size</FONT> 返回对像内数据的大小。 <BR><BR><FONT color=#ff0000>State</FONT> 返加对像状态是否打开。 <BR><BR><FONT color=#ff0000>Type</FONT> 指定或返回的数据类型，可选参数为： <BR>adTypeBinary =1 <BR>adTypeText =2 <BR><BR><IMG height=20 src="http://www.cnitblog.com/Emoticons/QQ/laf.gif" width=20 border=0><IMG height=20 src="http://www.cnitblog.com/Emoticons/QQ/laf.gif" width=20 border=0><IMG height=20 src="http://www.cnitblog.com/Emoticons/QQ/laf.gif" width=20 border=0><IMG height=20 src="http://www.cnitblog.com/Emoticons/QQ/laf.gif" width=20 border=0><IMG height=20 src="http://www.cnitblog.com/Emoticons/QQ/laf.gif" width=20 border=0></TD></TR></TBODY></TABLE><img src ="http://www.cnitblog.com/aiut/aggbug/4643.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-11-17 22:12 <a href="http://www.cnitblog.com/aiut/archive/2005/11/17/4643.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]小偷是怎样炼成的(asp,小偷,xmlhttp,正则,joyo.com) 作者：blue1019</title><link>http://www.cnitblog.com/aiut/archive/2005/11/17/4642.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Thu, 17 Nov 2005 13:57:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/11/17/4642.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/4642.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/11/17/4642.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/4642.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/4642.html</trackback:ping><description><![CDATA[<TABLE class="fixedTable blogpost" cellSpacing=0 width="100%" border=0>
<TBODY>
<TR>
<TD class=ellipse><SPAN class=bvTitle id=subjcns!1pvHzJ2FFuxbZKKCb2_fpGcA!243><STRONG>小偷是怎样炼成的(asp,小偷,xmlhttp,正则,joyo.com)<BR>作者：blue1019<BR>来源：<A href="http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!305.entry">http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!305.entry</A></STRONG></SPAN></TD></TR>
<TR>
<TD class=bvh8><STRONG></STRONG></TD></TR>
<TR>
<TD id=msgcns!1pvHzJ2FFuxbZKKCb2_fpGcA!243>
<DIV><FONT color=#3366ff><STRONG>关于</STRONG></FONT></DIV>
<DIV><FONT color=#3366ff>”认真编程“分类写的是一些编程经验，无相关知识将无法看懂。</FONT></DIV>
<DIV>&nbsp;&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>这几个月我们的商城建设起来了，“哈尔滨购物网”成了名副其实的购物网。<BR>这时间里相关部门就开始研究其他的购物网，比如当当，卓越。他们想要一份以excel形式存储的包含上述网站的商品信息以便统计、分析。当然卓越、当当没有什么理由把数据都给我们，于是我们想到了“偷”。于是我把周杰伦的七里香放进cd-rom驱动器开始了“盗窃”。</DIV>
<DIV>&nbsp;</DIV>
<DIV>一切从<A href="http://www.baidu.com/"><FONT color=#0d5d91>www.baidu.com</FONT></A>开始，在搜索的文本框里输入“asp 小偷”很多的信息就被检索出来了。我进入了一个叫“ASP小偷(远程数据获取)程序入门教程”的标题:</DIV>
<DIV><A href="http://www.pconline.com.cn/pcedu/empolder/wz/asp/0505/628553.html"><FONT color=#0d5d91>http://www.pconline.com.cn/pcedu/empolder/wz/asp/0505/628553.html</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>总结了文章的内容得出结论，“偷”其实就是通过微软的XMLHTTP这个COM组件进行的。还好XMLHTTP这个词并不陌生。</DIV>
<DIV><BR>我又在baidu上检索到“xmlHTTP技术资料"这条信息。</DIV>
<DIV><A href="http://www.youren.com/Article/programme/xml/200505/4768.html"><FONT color=#0d5d91>http://www.youren.com/Article/programme/xml/200505/4768.html</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>XMLHTTP能干很多事情，但是在这里我们要它干的只是：将指定的网页的HTML代码读出。<BR>如果通过程序读出对方（当当、卓越）的相应HTML代码就好办了，因为商品数据就存储在那庞杂的代码中。</DIV>
<DIV><BR>这很简单，我接着写了如下函数：</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>function getBody(infopageurl)<BR></STRONG>'功能：取得指定网址的html代码<BR>'参数：infopageurl 网页地址</DIV>
<DIV><STRONG>if infopageurl&lt;&gt;"" then<BR>&nbsp;dim xmlHttp<BR>&nbsp;set xmlHttp=server.createobject("MSXML2.XMLHTTP")</STRONG>‘声明XMLHTTP对象</DIV>
<DIV><STRONG>&nbsp;xmlHttp.open "GET",infopageurl,false<BR>&nbsp;xmlHttp.send</STRONG>’上面这两就句就是调用的形式，调用后程序会堵塞在send这句，直到内容被返回。<BR><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getBody=BytesToBstr(xmlhttp.responsebody,"GB2312")</STRONG>‘然后通过xmlhttp.responsebody属性将返回内容读出，这里用到一个BytesToBstr函数将在后面说明。</DIV>
<DIV><STRONG>&nbsp;set xmlHttp=nothing<BR>end if&nbsp;<BR>end function</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV>关于BytesToBstr,开始返回的结果没有经过这个函数处理，结果返回的汉字是一堆乱码。什么原因就不用深究了。我到<A href="http://www.chinaz.com/"><FONT color=#0d5d91>www.chinaz.com</FONT></A>下载了几个”小偷’的程序，发现里面不约而同的都含有这个函数。大概就是用adodb.stream对结果字符进行了转换。我把它加到我的函数里结果就正常了。</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>Function BytesToBstr(body,Cset) </STRONG></DIV>
<DIV><STRONG>&nbsp;dim objstream <BR>&nbsp;<BR>&nbsp;set objstream = Server.CreateObject("adodb.stream") <BR>&nbsp;<BR>&nbsp;objstream.Type = 1 <BR>&nbsp;<BR>&nbsp;objstream.Mode = 3 <BR>&nbsp;<BR>&nbsp;objstream.Open <BR>&nbsp;<BR>&nbsp;objstream.Write body <BR>&nbsp;<BR>&nbsp;objstream.Position = 0 <BR>&nbsp;<BR>&nbsp;objstream.Type = 2 <BR>&nbsp;<BR>&nbsp;objstream.Charset = Cset <BR>&nbsp;<BR>&nbsp;BytesToBstr = objstream.ReadText <BR>&nbsp;<BR>&nbsp;objstream.Close <BR>&nbsp;<BR>&nbsp;set objstream = nothing </STRONG></DIV>
<DIV><STRONG>End Function</STRONG></DIV>
<DIV><BR>html代码取回来了，我们怎么从中取得需要的数据？答案是正则表达式。</DIV>
<DIV>这里是关于正则表达式的参考<BR><A href="http://www.51windows.net/pages/vbscript/html/reconIntroductionToRegularExpressions.htm"><FONT color=#0d5d91>http://www.51windows.net/pages/vbscript/html/reconIntroductionToRegularExpressions.htm</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>正则表达达式就象是一种简单的语言。它用一些特殊的字符模糊地描述一个字符串。然后可以通过程序去检查一个字符串中是否包含你描述的那种字符串，还可以将你描述的字符从一个字符串中取出，这里我们就是利用这个功能来获取需要的数据。</DIV>
<DIV>&nbsp;</DIV>
<DIV>举起例子比较容易理解：</DIV>
<DIV><STRONG><FONT color=#3366ff>*</FONT> 匹配前面的子表达式零次或多次。例如，zo*（正则表达式） 能匹配 z 、 zoo、zooooo、zoooooooooo<BR><FONT color=#3366ff>+</FONT> 匹配前面的子表达式一次或多次。例如，zo+ 能匹配 zo 以及 zoo，但不能匹配 "z"。<BR><FONT color=#3366ff>\d</FONT> 匹配一个数字字符。等价于 [0-9]。&nbsp; 例如， \d+ 可以匹配 1，123，987<FONT color=#000000>6</FONT></STRONG></DIV>
<DIV>
<TABLE cellSpacing=0>
<TBODY>
<TR vAlign=top>
<TD width="16%"><STRONG><FONT color=#3366ff>.</FONT></STRONG></TD>
<TD width="84%"><STRONG>匹配除 "\n" 之外的任何单个字符。</STRONG></TD></TR></TBODY></TABLE></DIV>
<DIV><FONT color=#3366ff>?</FONT> <STRONG>当该字符紧跟在任何一个其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 后面时，匹配模式是非贪婪的。非贪婪模式尽可能少的匹配所搜索的字符串，而默认的贪婪模式则尽可能多的匹配所搜索的字符串。例如，对于字符串 "oooo"，'o+?' 将匹配单个 "o"，而 'o+' 将匹配所有 'o'。</STRONG> </DIV>
<DIV>&nbsp;</DIV>
<DIV>下面要做的就是分析商品数据在html代码中存放的特征，然后写出正则表达式将其取出。<BR>例如，joyo商品的市场价格数据在html代码中是这样存储的“市场价：15.00元”，要做的是把以“市场价：”开头，“元”结尾之间的数值取出。下面函数就实现了这个功能：</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>function Topic(sHtmlcode)<BR></STRONG>'功能：返回joyo.com商品页面的市场价格数值<BR>'参数：shtmlcode 商品页的html代码</DIV>
<DIV><STRONG>Set regEx = New RegExp</STRONG>'建立使用正则表达式的对象</DIV>
<DIV><STRONG>regEx.IgnoreCase =true<BR>regEx.Global = True<BR>regEx.Pattern ="市场价：(.+?)元"设置表达式</STRONG></DIV>
<DIV><STRONG>Set Matches = regEx.Execute(shtmlcode)</STRONG>'执行表达式将所有符合描述的字符传存放到一个集合里。</DIV>
<DIV><STRONG>for each sMatch in Matches<BR>Topic=sMatch.SubMatches(0)</STRONG>'submatches(0)带表第一个子匹配,既小括号中的数值<BR><STRONG>exit for<BR>next&nbsp;<BR>set regEx=nothing<BR>end function</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV>其他的数据也用同样的方法取得。写正则表达式是一个很有趣而且很复杂的工作。期间我遇到写不出来的，就去CSDN.net的论坛去提问，总是可以得到帮助。</DIV>
<DIV>&nbsp;</DIV>
<DIV>还有一点要思考的是：是不是这个表达式对所有的商品页面都适用。如果所有的商品都是用一个asp程序显示那就可以，但是joyo.com不是，它的不同分类中html代码的格式是不同的，所以我们要写几个正则表达式来分别匹配不同形式的数据（比如有些页面中市场价格是这样存储的“市场价：&lt;b&gt;15.00&lt;/b&gt;元"）。</DIV>
<DIV><BR>有了这些函数我们就可以用给定的商品网页地址取得相应的数据了。但是这些网站的商品一般都有万余种，如何获取这些地址就不是那么容易了。这个过程因站而异，这也是真正需要“小偷”智慧的工作之一。</DIV>
<DIV>&nbsp;</DIV>
<DIV>拿joyo.com进行分析。进入首页之后我发现里面有个”产品搜索“，选择“所有类别”，关键字置空，点击那个”GO!"检索出了21684条记录。这应该就是joyo.com的所有商品信息了，来的太容易我简直不敢相信。</DIV>
<DIV><BR>检索页上包含有10条商品的连接，用正则取得后，再取得转向后10条记录（即下一页）的连接。如此循环就会得出所有商品信息。我用access建了一个表来存放它们。编好了程序挂到机器上就睡觉去了。</DIV>
<DIV><BR>这是一个检索结果页的连接：<BR><A href="http://www.joyo.com/ProdSearch/prodsearch.asp?kind=&amp;limitBefore=10&amp;vname=&amp;sorttype=undefined&amp;uid=u5swcqykpzsis0qaiwg79sg5u"><FONT color=#0d5d91>http://www.joyo.com/ProdSearch/prodsearch.asp?kind=&amp;limitBefore=10&amp;vname=&amp;sorttype=undefined&amp;uid=u5swcqykpzsis0qaiwg79sg5u</FONT></A><BR>其中limitBefore=10 当前页第一条记录前有10条记录，即这一页的第一条是总的第11条记录。</DIV>
<DIV>&nbsp;</DIV>
<DIV>第二天兴奋地来到机器上一看，发现记录只有700多条。很郁闷，程序我没加容错处理因为我发现vbscript的错误处理比vb中的还要简略。似乎连on error goto LABEL都不可以使用。我在检索页点来点去希望找出错误的根源，结果发现当其中limitBefore大于750的时候后面就没有记录了。原来是这样。joyo.com的程序员没有让我们这么容易的得到所有数据。这条路是不能走了。</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>下面我开始分析检索结果中商品信息页面的连接：<BR><A href="http://www.joyo.com/shop/shop_product.asp?uid=u5swcqykpzsis0qaiwg79sg5u&amp;prodid=bkbk507440"><FONT color=#0d5d91>http://www.joyo.com/shop/shop_product.asp?uid=u5swcqykpzsis0qaiwg79sg5u&amp;prodid=bkbk507440</FONT></A><BR>经分析 prodid=bkbk507440 是这个产品的唯一标识，bkbk表示该产品的所属分类“图书”</DIV>
<DIV>&nbsp;</DIV>
<DIV>这是一些其他的主要分类标识：<BR>bkbk 图书<BR>bkmu 音乐<BR>itit 数码<BR>bkbh 日用<BR>itrj 数码产品<BR>bkgm 游戏<BR>bkys 影视</DIV>
<DIV>&nbsp;</DIV>
<DIV>只要我遍历所有的prodid然后找出存在的商品页面就可以了。然而怎么判断该prodid是否存在呢，我在地址栏上胡乱打了一个prodid返回了出错结果页面。</DIV>
<DIV>&nbsp;</DIV>
<DIV><A href="http://www.joyo.com/errormsg.asp?uid=u5swcqykpzsis0qaiwg79smuw&amp;err=GET%C7%EB%C7%F3%B5%C4%C9%CC%C6%B7ID%B2%BB%B4%E6%D4%DA%A3%AC%B2%D9%D7%F7%CE%DE%B7%A8%BC%CC%D0%F8%A3%A1"><FONT color=#0d5d91>http://www.joyo.com/errormsg.asp?uid=u5swcqykpzsis0qaiwg79smuw&amp;err=GET%C7%EB%C7%F3%B5%C4%C9%CC%C6%B7ID%B2%BB%B4%E6%D4%DA%A3%AC%B2%D9%D7%F7%CE%DE%B7%A8%BC%CC%D0%F8%A3%A1</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>出错页上有一张红色的“警钟”图案，我估计正常的页面上是不可能包含此图片的。于是以此作为判断prodid是否存在的依据。遍历所有prodid,如果在返回结果html中发现“警钟”图片则不做处理，否则就从页面中取出需要的信息。</DIV>
<DIV><BR>遍历6位的prodid是个漫长的过程，粗略的估算，如果每个操作用时1秒的话,则最少需要999999次循,环即999999秒（999999/3600=277多小时）。这显然是太长了，于是我又做了一些优化，发现第一位数字只在0-5之间变化，第二为数字只在0-1之间变化。这样大大的缩短了时间(519999/3600=144多小时),实际的时间更乐观。</DIV>
<DIV>&nbsp;</DIV>
<DIV>经过几天的调试终于把图书分类下载完了，接下来我又接着优化程序，做一个更有效率的“小偷”。</DIV></TD></TR></TBODY></TABLE><img src ="http://www.cnitblog.com/aiut/aggbug/4642.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-11-17 21:57 <a href="http://www.cnitblog.com/aiut/archive/2005/11/17/4642.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]获取远程服务器数据（asp，adodb.stream，保存远程图片，XMLHTTP）  作者：blue1019</title><link>http://www.cnitblog.com/aiut/archive/2005/11/17/4641.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Thu, 17 Nov 2005 13:53:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/11/17/4641.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/4641.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/11/17/4641.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/4641.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/4641.html</trackback:ping><description><![CDATA[<TABLE class="fixedTable blogpost" cellSpacing=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top><SPAN class=bold id=LastMDatecns!1pvHzJ2FFuxbZKKCb2_fpGcA!305><STRONG>作者：blue1019<BR>来源：<A href="http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!305.entry">http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!305.entry</A><BR><BR>10月10日</STRONG></SPAN></TD></TR>
<TR>
<TD height=4><STRONG></STRONG></TD></TR>
<TR>
<TD class=blackline><STRONG></STRONG></TD></TR>
<TR>
<TD height=4><STRONG></STRONG></TD></TR>
<TR>
<TD class=ellipse><SPAN class=bvTitle id=subjcns!1pvHzJ2FFuxbZKKCb2_fpGcA!305><STRONG>获取远程服务器数据（asp，adodb.stream，保存远程图片，XMLHTTP）</STRONG></SPAN></TD></TR>
<TR>
<TD class=bvh8><STRONG></STRONG></TD></TR>
<TR>
<TD id=msgcns!1pvHzJ2FFuxbZKKCb2_fpGcA!305>
<DIV>本文章对使用xmlhttp下载其他服务器信息的技术做了进一步的研究,如不熟悉请先阅读</DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN>小偷是怎样炼成的</SPAN></DIV>
<DIV><A href="http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!243.entry"><FONT color=#0d5d91>http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!243.entry</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>关于XMLHTTP的细节可以参考</DIV>
<DIV><A href="http://www.channel7.cn/2004/11-18/14458.html"><FONT color=#0d5d91>http://www.channel7.cn/2004/11-18/14458.html</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>关于adodb.stream的细节可以参考</DIV>
<DIV><A href="http://www.daima.com.cn/Info/32/Info22138/"><FONT color=#0d5d91>http://www.daima.com.cn/Info/32/Info22138/</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>下面重新注释了BytesToBstr函数,它的作用是把由xmlhttp.responsebody返回的字节数组转换成文本字符串,如果数据要用做屏幕输入则必须转换否则汉字会出现乱码.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;Function BytesToBstr(body)<BR>&nbsp;&nbsp;'Cset:GB2312 UTF-8<BR>&nbsp;&nbsp;dim objstream <BR>&nbsp;&nbsp;set objstream = Server.CreateObject("adodb.stream") <BR>&nbsp;&nbsp;with objstream<BR>&nbsp;&nbsp;&nbsp;.Type = 1 '<STRONG>设置返回数据类型为二进制<BR></STRONG>&nbsp;&nbsp;&nbsp;.Mode = 3 '打开模式为读写<BR>&nbsp;&nbsp;&nbsp;.Open&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;.Write body&nbsp; '<STRONG>将指定的数据装入对像中 body为内容<BR></STRONG>&nbsp;&nbsp;&nbsp;.Position = 0 '<STRONG>指定对像内数据的当前指针<BR></STRONG>&nbsp;&nbsp;&nbsp;.Type = 2&nbsp; '<STRONG>设置返回数据类型为文本<BR></STRONG>&nbsp;&nbsp;&nbsp;.Charset = Cset&nbsp; '<STRONG>设定字符集类型</STRONG><BR>&nbsp;&nbsp;&nbsp;BytesToBstr = .ReadText '<STRONG>取对象内的文本<BR></STRONG>&nbsp;&nbsp;&nbsp;.Close <BR>&nbsp;&nbsp;end with<BR>&nbsp;&nbsp;set objstream = nothing <BR>&nbsp;End Function </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>获取其他服务器的数据和获取文本是一个道理，通过图片的url获取图片的数据处理,只是保存的时候不需要把它转换成字符串了。这里利用adodb.stream的SaveToFile方法将其保存在本地服务器上。</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;Public function saveimage(tofile)<BR>&nbsp;&nbsp;dim objStream,imgs<BR>&nbsp;&nbsp;imgs=getBody(sUrl)'<STRONG>取得图片的具休内容的过程<BR></STRONG>&nbsp;&nbsp;Set objStream = Server.CreateObject("ADODB.Stream")'<STRONG>建立ADODB.Stream对象，必须要ADO 2.5以上版本<BR></STRONG>&nbsp;&nbsp;with objStream<BR>&nbsp;&nbsp;&nbsp;.Type =1'<STRONG>以二进制模式打开</STRONG><BR>&nbsp;&nbsp;&nbsp;.Open<BR>&nbsp;&nbsp;&nbsp;.write imgs'<STRONG>将字符串内容写入缓冲</STRONG><BR>&nbsp;&nbsp;&nbsp;.SaveToFile server.mappath(tofile),2'<STRONG>将缓冲的内容写入文件</STRONG><BR>&nbsp;&nbsp;&nbsp;.Close()<BR>&nbsp;&nbsp;end with&nbsp;<BR>&nbsp;&nbsp;set objstream=nothing<BR>&nbsp;end function</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>实现了保存文本数据和二进制数据，那就无所不能了*^_^*</DIV>
<DIV>&nbsp;</DIV>
<DIV>附一个包括简单功能类完整代码：</DIV>
<DIV>---------------------------------------------------------------------------</DIV>
<DIV><FONT color=#000080>Class xhttp</FONT></DIV>
<DIV><FONT color=#000080>&nbsp;private cset,sUrl</FONT></DIV>
<DIV><FONT color=#000080>&nbsp;Private Sub Class_Initialize()<BR>&nbsp;&nbsp;cset="UTF-8"<BR>&nbsp;end sub<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;Private Sub Class_Terminate()<BR>&nbsp;End Sub</FONT></DIV>
<DIV><BR><FONT color=#000080>&nbsp;Public Property LET URL(theurl)<BR>&nbsp;&nbsp;sUrl=theurl<BR>&nbsp;end property<BR>&nbsp;<BR>&nbsp;public property GET BasePath()<BR>&nbsp;&nbsp;BasePath=mid(sUrl,1,InStrRev(sUrl,"/")-1)<BR>&nbsp;end property<BR>&nbsp;<BR>&nbsp;public property GET FileName()<BR>&nbsp;&nbsp;FileName=mid(sUrl,InStrRev(sUrl,"/")+1)<BR>&nbsp;end property</FONT></DIV>
<DIV><FONT color=#000080>&nbsp;public property GET Html()<BR>&nbsp;&nbsp;Html=BytesToBstr(getBody(sUrl))<BR>&nbsp;end property</FONT></DIV>
<DIV><FONT color=#000080>&nbsp;private Function BytesToBstr(body)<BR>&nbsp;&nbsp;'Cset:GB2312 UTF-8<BR>&nbsp;&nbsp;dim objstream <BR>&nbsp;&nbsp;set objstream = Server.CreateObject("adodb.stream") <BR>&nbsp;&nbsp;with objstream<BR>&nbsp;&nbsp;&nbsp;.Type = 1 '设置返回数据类型为二进制<BR>&nbsp;&nbsp;&nbsp;.Mode = 3 '打开模式为读写<BR>&nbsp;&nbsp;&nbsp;.Open&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;.Write body&nbsp; '将指定的数据装入对像中 body为内容<BR>&nbsp;&nbsp;&nbsp;.Position = 0 '指定对像内数据的当前指针<BR>&nbsp;&nbsp;&nbsp;.Type = 2&nbsp; '设置返回数据类型为文本<BR>&nbsp;&nbsp;&nbsp;.Charset = Cset&nbsp; '设定字符集类型<BR>&nbsp;&nbsp;&nbsp;BytesToBstr = .ReadText '取对象内的文本<BR>&nbsp;&nbsp;&nbsp;.Close <BR>&nbsp;&nbsp;end with<BR>&nbsp;&nbsp;set objstream = nothing <BR>&nbsp;End Function </FONT></DIV>
<DIV><BR><FONT color=#000080>&nbsp;private function getBody(surl)<BR>&nbsp;&nbsp;dim xmlHttp<BR>&nbsp;&nbsp;set xmlHttp=server.createobject("MSXML2.XMLHTTP")<BR>&nbsp;&nbsp;xmlHttp.open "GET",surl,false<BR>&nbsp;&nbsp;xmlHttp.send<BR>&nbsp;&nbsp;if xmlHttp.readystate&lt;&gt;4 then <BR>&nbsp;&nbsp;&nbsp;exit function<BR>&nbsp;&nbsp;end if<BR>&nbsp;&nbsp; getBody=xmlhttp.responsebody<BR>&nbsp;&nbsp;set xmlHttp=nothing<BR>&nbsp;end function<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;Public function saveimage(tofile)<BR>&nbsp;&nbsp;dim objStream,imgs<BR>&nbsp;&nbsp;imgs=getBody(sUrl)'取得图片的具休内容的过程<BR>&nbsp;&nbsp;Set objStream = Server.CreateObject("ADODB.Stream")'建立ADODB.Stream对象，必须要ADO 2.5以上版本<BR>&nbsp;&nbsp;with objStream<BR>&nbsp;&nbsp;&nbsp;.Type =1'以二进制模式打开<BR>&nbsp;&nbsp;&nbsp;.Open<BR>&nbsp;&nbsp;&nbsp;.write imgs'将字符串内容写入缓冲<BR>&nbsp;&nbsp;&nbsp;.SaveToFile server.mappath(tofile),2'-将缓冲的内容写入文件<BR>&nbsp;&nbsp;&nbsp;.Close()<BR>&nbsp;&nbsp;end with&nbsp;<BR>&nbsp;&nbsp;set objstream=nothing<BR>&nbsp;end function<BR>&nbsp;<BR>end class&nbsp;</FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080>TEST:</FONT></DIV>
<DIV><FONT color=#000080>dim o </FONT></DIV>
<DIV><FONT color=#000080>set o=new xhttp</FONT></DIV>
<DIV><FONT color=#000080>o.url=</FONT><A href="http://www.baidu.com/img/logo-yy.gif"><FONT color=#000080>"http://www.baidu.com/img/logo-yy.gif</FONT></A><FONT color=#000080>"</FONT></DIV>
<DIV><FONT color=#000080>o.saveimage "blue.gif"</FONT></DIV>
<DIV><FONT color=#000080>set o=nothing</FONT></DIV></TD></TR></TBODY></TABLE><img src ="http://www.cnitblog.com/aiut/aggbug/4641.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-11-17 21:53 <a href="http://www.cnitblog.com/aiut/archive/2005/11/17/4641.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>.net中xmlhttp下载文件的方法参考[转载]</title><link>http://www.cnitblog.com/aiut/archive/2005/11/17/4639.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Thu, 17 Nov 2005 13:24:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/11/17/4639.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/4639.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/11/17/4639.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/4639.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/4639.html</trackback:ping><description><![CDATA[<P>来源：<A href="http://www.caspnet.com.cn/blog/post/111.html">http://www.caspnet.com.cn/blog/post/111.html</A><BR><BR>下面为完整的源代码</P>
<P>
<TABLE style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellSpacing=0 cellPadding=6 width="95%" align=center border=0>
<TBODY>
<TR>
<TD style="WORD-WRAP: break-word" bgColor=#f3f3f3><FONT style="FONT-WEIGHT: bold; COLOR: #990000">以下是引用片段：</FONT><BR>&lt;%@&nbsp;Page&nbsp;language="c#"%&gt;&nbsp; <BR>&lt;%@import&nbsp;namespace=MSXML2%&gt;&nbsp; <BR>&lt;script&nbsp;language="c#"&nbsp;runat="server"&gt;&nbsp; <BR>private&nbsp;void&nbsp;Page_Load(object&nbsp;sender,&nbsp;System.EventArgs&nbsp;e)&nbsp; <BR>{&nbsp; <BR>string&nbsp;Url&nbsp;=&nbsp;"/blog/upload/20056222116262.gif";&nbsp; <BR>string&nbsp;StringFileName&nbsp;=&nbsp;Url.Substring(Url.LastIndexOf("/")&nbsp;+&nbsp;1);&nbsp; <BR>string&nbsp;StringFilePath&nbsp;=&nbsp;Request.PhysicalApplicationPath;&nbsp; <BR>if(!StringFilePath.EndsWith("/"))&nbsp;StringFilePath&nbsp;+=&nbsp;"/";&nbsp; <BR>MSXML2.XMLHTTP&nbsp;_xmlhttp&nbsp;=&nbsp;new&nbsp;MSXML2.XMLHTTPClass();&nbsp; <BR>_xmlhttp.open("GET",Url,false,null,null);&nbsp; <BR>_xmlhttp.send("");&nbsp; <BR>if(&nbsp;_xmlhttp.readyState&nbsp;==&nbsp;4&nbsp;)&nbsp; <BR>{&nbsp; <BR>if(System.IO.File.Exists(StringFilePath&nbsp;+&nbsp;StringFileName))&nbsp; <BR>System.IO.File.delete(StringFilePath&nbsp;+&nbsp;StringFileName);&nbsp; <BR>System.IO.FileStream&nbsp;fs&nbsp;=&nbsp;new&nbsp;System.IO.FileStream(StringFilePath&nbsp;+&nbsp;StringFileName,&nbsp;System.IO.FileMode.createNew);&nbsp; <BR>System.IO.BinaryWriter&nbsp;w&nbsp;=&nbsp;new&nbsp;System.IO.BinaryWriter(fs);&nbsp; <BR>w.Write((byte[])_xmlhttp.responseBody);&nbsp; <BR>w.Close();&nbsp; <BR>fs.Close();&nbsp; <BR>Response.Write&nbsp;("文件已经得到。&lt;br&gt;&lt;a&nbsp;href=’"&nbsp;+&nbsp;Request.ApplicationPath&nbsp;+&nbsp;"\\"&nbsp;+&nbsp;StringFileName&nbsp;+"’&nbsp;target=’_blank’&gt;");&nbsp; <BR>Response.Write&nbsp;("查看"&nbsp;+&nbsp;StringFileName&nbsp;+&nbsp;"&lt;/a&gt;");&nbsp; <BR>}&nbsp; <BR>else&nbsp; <BR>//Response.Write&nbsp;(_xmlhttp.statusText);&nbsp; <BR>Response.End();&nbsp; <BR>}&nbsp; <BR>&lt;/script&gt;&nbsp;</TD></TR></TBODY></TABLE></P><BR>
<P><FONT color=#1111ee></FONT>&nbsp;</P>
<P><FONT color=#1111ee></FONT>&nbsp;</P>
<P><FONT color=#1111ee>//试分析 .NET 下用MSXML远程下载文件跟处理方法</FONT></P>
<P><FONT color=#1111ee>//声明为 C#语言</FONT><BR>&lt;%@ Page language="c#"%&gt; </P>
<P><FONT color=#1111ee>//导入MSXML2空间，表示下面要用到这个空间里的一些内容</FONT><BR>&lt;%@import namespace=MSXML2%&gt; <BR><FONT color=#1111ee>//语言C# 运行在服务器端</FONT><BR>&lt;script language="c#" runat="server"&gt; <BR></P>
<P>private void Page_Load(object sender, System.EventArgs e) <BR>{ </P>
<P><FONT color=#1111ee>//定义变量&nbsp; Url 为一个绝对目录地址</FONT><BR>string Url = "/blog/upload/20056222116262.gif";</P>
<P><FONT color=#1111ee>//定义变量&nbsp;取得以 / 为分隔符的&nbsp;最后那个数组数据&nbsp; 得到&nbsp;20056222116262.gif<BR></FONT>string StringFileName = Url.Substring(Url.LastIndexOf("/") + 1); </P>
<P><FONT color=#1111ee>//定义变量，得到当前文件的物理路径</FONT><BR>string StringFilePath = Request.PhysicalApplicationPath; </P>
<P><FONT color=#1111ee>//如果路径最后的字符不为 / 则加上 /</FONT><BR>if(!StringFilePath.EndsWith("/")) StringFilePath += "/"; </P>
<P><FONT color=#1111ee>//申请 XMLHTTP对象</FONT></P>
<P>MSXML2.XMLHTTP _xmlhttp = new MSXML2.XMLHTTPClass(); </P>
<P><FONT color=#1111ee>// 用 GET方式　向URL地址　需要等待服务器回应 False<BR></FONT>_xmlhttp.open("GET",Url,false,null,null); </P>
<P><FONT color=#1111ee>//发送请求</FONT><BR>_xmlhttp.send("");</P>
<P><FONT color=#1111ee>//如果返回的是　服务器回应完毕，文件已经下载成功　则进入下一步</FONT>&nbsp;<BR>if( _xmlhttp.readyState == 4 ) <BR>{ </P>
<P><FONT color=#1111ee>//查看　当前路径，当前文件名的　有没有存在这个文件</FONT><BR>if(System.IO.File.Exists(StringFilePath + StringFileName)) </P>
<P><FONT color=#1111ee>//如果存在就删除</FONT><BR>System.IO.File.delete(StringFilePath + StringFileName); </P>
<P><FONT color=#1111ee>//创建文件流格式</FONT><BR>System.IO.FileStream fs = new System.IO.FileStream(StringFilePath + StringFileName, System.IO.FileMode.createNew); </P>
<P><FONT color=#1111ee>//用二进制模式打开<BR></FONT>System.IO.BinaryWriter w = new System.IO.BinaryWriter(fs); </P>
<P><FONT color=#1111ee>//写入到文件中。。内容为　XMLHTTP抓取的数据。</FONT><BR>w.Write((byte[])_xmlhttp.responseBody); </P>
<P><FONT color=#1111ee>//关闭对像　<BR></FONT>w.Close(); <BR>fs.Close(); </P>
<P><BR>Response.Write ("文件已经得到。&lt;br&gt;&lt;a href='" + Request.ApplicationPath + "\\" + StringFileName +"' target='_blank'&gt;"); <BR>Response.Write ("查看" + StringFileName + "&lt;/a&gt;"); <BR>} <BR>else </P>
<P><FONT color=#1111ee>//如果采集不到数据，则停止一切操作<BR></FONT>//Response.Write (_xmlhttp.statusText); <BR>Response.End(); <BR>} <BR>&lt;/script&gt; <BR></P><img src ="http://www.cnitblog.com/aiut/aggbug/4639.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-11-17 21:24 <a href="http://www.cnitblog.com/aiut/archive/2005/11/17/4639.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]flex的配置和运行（二） Author: kenshin</title><link>http://www.cnitblog.com/aiut/archive/2005/10/28/3636.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Fri, 28 Oct 2005 05:50:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/28/3636.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3636.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/28/3636.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3636.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3636.html</trackback:ping><description><![CDATA[来源：<A href="http://www.k-zone.cn/Blog/blogview.asp?logID=83">http://www.k-zone.cn/Blog/blogview.asp?logID=83</A>&nbsp;&nbsp;&nbsp;&nbsp; 作者：kenshin<BR><BR>终于到周末了，晚上给大家加班贴出flex的教程第二辑 <IMG src="http://www.k-zone.cn/Blog/images/smilies/icon2_lol.gif" align=absMiddle border=0> <BR><BR>④&nbsp;&nbsp;安装eclipse，在这个地址下载eclipse for wtp-all-in-one-0.7-win32.zip，本机也有！<BR><A href="http://www.eclipse.org/downloads/download.php?file=/webtools/downloads/drops/R-0.7-200507290654/wtp-all-in-one-0.7-win32.zip" target=_blank>http://www.eclipse.org/downloads/download.php?file=/webtools/downloads/drops/R-0.7-200507290654/wtp-all-in-one-0.7-win32.zip</A><BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_173659_b91e5.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>下载完以后，把eclipse for wtp-all-in-one-0.7的rar解压缩到任意目录下面，我选择的是f:的根目录下面，关于eclipse for wtp-all-in-one-0.7这个版本，已经自带了关于j2ee的插件，不需要在进行额外的配置了！然后运行eclipse.exe文件，它首先需要选择一个workspace，用默认的就可以了。进行配置：<BR>Ⅰ　配置java-buildpath，如下图配置：<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_173724_oldr6.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>Ⅱ　 配置JDK，TOMCAT运行的时候需要JDK，eclipse自动找到的是jre，如下图:<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_173955_rogu11.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>选择add，之后按如下图进行配置：<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_173929_nkcq10.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>主要就是找到刚才安装的jdk的目录，并且给JRE起一个名字！配置成功后，如下图：<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_173955_rogu11.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>Ⅲ　配置xml 和 internet 缓存，在web应用中通常有很多的xml文件，默认情况下wtp会去验证这些xml文件，这就需要有这些xml文件的定义dtd或者xsd文件。wtp默认的会自动去下载，下载下来之后可以缓存之后供以后使用。所以首先我们要打开缓存功能。见下图，把disable cashing的勾去掉即可。<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_174020_b91e12.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>也可以把常用的xml文件的定义文件配置在xmlcatalog里边，这样进行xml验证的时候会自动使用这些文件，见下图：<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_174044_63u013.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>Ⅳ　配置tomcat服务器，现在我们来配置tomcat，其他服务器的配置大致相同，如下图所示：<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_174114_07yc14.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>点击上图中的add按钮，选择刚才安装好的tomcat的版本号，比如：tomcat5.0<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_174140_3zr615.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_174156_xum116.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>写入tomcat的名称，路径，最重要的是选择刚才配置好的JRE的名称，比如JDK1.5，然后选择Finish即可。这样eclipse for wtp-all-in-one-0.7就配置完毕，下面来进行一下check，看看是否成功！<BR>Ⅴ　开发一个JSP<BR>　　关于开发jsp的部分，在本文里面就不在进行叙述了！<BR>⑤&nbsp;&nbsp;以上就是JDK+tomcat+eclipse开发jsp的过程，下面叙述用eclipse开发flex的部分，首先当第一次运行eclipse的时候，它会让你选择一个路径来当作workspace，如果你新建了一个project的话，例如你新建立的project名称叫做FX-Blog，eclipse就会在workspace/FX-Blog的下面建立如下图的文件夹结构：<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/21_174249_tqiw17.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>其中javasource下面放的就是java的文件，webContent下面放的就是jsp的文件。<BR>而且eclipse的所有关于这个project的配置文件全部放在eclipse的workspace\FX-Blog的目录下面，只要把这个文件夹copy到环境相同的另一台机器上，就不再需要配置eclipse了！现在进行flex+eclipse的配置，首先把tomcat中的webapps/samples的文件夹下面的WEB-INF和META-INF这2个文件夹copy到eclipse的workspace的你自己建立的project，例如F:\eclipse\workspace\FX-Blog\WebContent\这个下面，覆盖原有的文件就可以，然后重新启动eclipse，之后在F:\eclipse\workspace\FX-Blog\WebContent\下面建立一个mxml文件，如果在eclisple中运行这个mxml文件，能运行成功的话，说明flex1.5+tomcat5.X+eclipse3.1+flex builder1.5+JDK1.5配置成<BR><img src ="http://www.cnitblog.com/aiut/aggbug/3636.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-28 13:50 <a href="http://www.cnitblog.com/aiut/archive/2005/10/28/3636.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转] flex的配置和运行（一）Author: kenshin</title><link>http://www.cnitblog.com/aiut/archive/2005/10/28/3633.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Fri, 28 Oct 2005 03:51:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/28/3633.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3633.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/28/3633.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3633.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3633.html</trackback:ping><description><![CDATA[来自 <A href="http://www.k-zone.cn/Blog/blogview.asp?logID=78">http://www.k-zone.cn/Blog/blogview.asp?logID=78</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 作者：kenshin<BR><BR>应广大朋友的要求，只好先写一些flex的配置吧！ <IMG src="http://www.k-zone.cn/Blog/images/smilies/icon2_cool.gif" align=absMiddle border=0> 本来想先整理fxblog来着，但是我想把它移植到flex 2 里面 看看效果，所有需要晚几天的时间，对不起大家了<BR><IMG src="http://www.k-zone.cn/Blog/images/smilies/icon2_sad.gif" align=absMiddle border=0> <BR><BR>① 首先下載 JDK1.5,从sun的网站上面就能下载，安装的时候，路径的选择最好是是在c盘根目录下面。比c:\JDK1.5。如果用eclipse运行java的话，不需要配置环境变数。<BR>② 然后下载tomcat5.x，去它的网站下载，然后安装，一路默认就可以，其中端口选择默认，必须输入admin的密码即可。运行tomcat5.x后，如下图进行配置：<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/19_115440_mjbp1.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>主要配置上面红色的线的部分（包括：虚拟机和java的classpath），只要和你刚才安装的jdk的路径一直就可以。之后运行<A href="http://localhost:8080,如果能看到欢迎画面，就表示jdk＋tomcat配置成功！/" target=_blank>http://localhost:8080,如果能看到欢迎画面，就表示jdk＋tomcat配置成功！</A><BR>③ 然后安装flex1.5，可以从mm的网站下载，下载时需要有效的信箱地址。<BR>也是一路的next，安装的目录选择默认就可以。安装后在C:\Program Files\Macromedia\Flex\下面会有2个文件，flex.jar和samples.jar，把他们copy到tomcat的webapps的目录下面，也就是C:\Tomcat 5.X\webapps\这个下面，然后重新启动tomcat，tomcat通过刚才copy过来的这2个jar文件，生成相应的文件夹，就是flex和samples的文件夹，如下图：<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/19_115518_vslz2.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>然后在ie里面<A href="http://localhost:8080/samples，如果下图如下：" target=_blank>http://localhost:8080/samples，如果下图如下：</A><BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/19_115559_xum13.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR>说明你的flex已经配置成功了80％。点击flex explorer的话，出现下图的画面，说明你的flex已经完全配置成功！：）<BR><IMG src="http://www.k-zone.cn/Blog/kenshinwlattachments/month_200510/19_123700_urky4.JPG" onload="javascript:if(this.width>screen.width-300)this.width=screen.width-300" border=0><BR><img src ="http://www.cnitblog.com/aiut/aggbug/3633.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-28 11:51 <a href="http://www.cnitblog.com/aiut/archive/2005/10/28/3633.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java正则表达式详解</title><link>http://www.cnitblog.com/aiut/archive/2005/10/21/3478.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Fri, 21 Oct 2005 09:58:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/21/3478.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3478.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/21/3478.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3478.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3478.html</trackback:ping><description><![CDATA[<A href="http://edu.yesky.com/edupxpt/18/2143018.shtml">http://edu.yesky.com/edupxpt/18/2143018.shtml</A><img src ="http://www.cnitblog.com/aiut/aggbug/3478.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-21 17:58 <a href="http://www.cnitblog.com/aiut/archive/2005/10/21/3478.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转帖-document.execCommand() 解析</title><link>http://www.cnitblog.com/aiut/archive/2005/10/20/3422.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Thu, 20 Oct 2005 02:50:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/20/3422.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3422.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/20/3422.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3422.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3422.html</trackback:ping><description><![CDATA[功能的确很多哦。<BR><BR>2D-Position 允许通过拖曳移动绝对定位的对象。 <BR>AbsolutePosition 设定元素的 position 属性为“absolute”(绝对)。 <BR>BackColor 设置或获取当前选中区的背景颜色。 <BR>BlockDirLTR 目前尚未支持。 <BR>BlockDirRTL 目前尚未支持。 <BR>Bold 切换当前选中区的粗体显示与否。 <BR>BrowseMode 目前尚未支持。 <BR>Copy 将当前选中区复制到剪贴板。 <BR>CreateBookmark 创建一个书签锚或获取当前选中区或插入点的书签锚的名称。 <BR>CreateLink 在当前选中区上插入超级链接，或显示一个对话框允许用户指定要为当前选中区插入的超级链接的 URL。 <BR>Cut 将当前选中区复制到剪贴板并删除之。 <BR>Delete 删除当前选中区。 <BR>DirLTR 目前尚未支持。 <BR>DirRTL 目前尚未支持。 <BR>EditMode 目前尚未支持。 <BR>FontName 设置或获取当前选中区的字体。 <BR>FontSize 设置或获取当前选中区的字体大小。 <BR>ForeColor 设置或获取当前选中区的前景(文本)颜色。 <BR>FormatBlock 设置当前块格式化标签。 <BR>Indent 增加选中文本的缩进。 <BR>InlineDirLTR 目前尚未支持。 <BR>InlineDirRTL 目前尚未支持。 <BR>InsertButton 用按钮控件覆盖当前选中区。 <BR>InsertFieldset 用方框覆盖当前选中区。 <BR>InsertHorizontalRule 用水平线覆盖当前选中区。 <BR>InsertIFrame 用内嵌框架覆盖当前选中区。 <BR>InsertImage 用图像覆盖当前选中区。 <BR>InsertInputButton 用按钮控件覆盖当前选中区。 <BR>InsertInputCheckbox 用复选框控件覆盖当前选中区。 <BR>InsertInputFileUpload 用文件上载控件覆盖当前选中区。 <BR>InsertInputHidden 插入隐藏控件覆盖当前选中区。 <BR>InsertInputImage 用图像控件覆盖当前选中区。 <BR>InsertInputPassword 用密码控件覆盖当前选中区。 <BR>InsertInputRadio 用单选钮控件覆盖当前选中区。 <BR>InsertInputReset 用重置控件覆盖当前选中区。 <BR>InsertInputSubmit 用提交控件覆盖当前选中区。 <BR>InsertInputText 用文本控件覆盖当前选中区。 <BR>InsertMarquee 用空字幕覆盖当前选中区。 <BR>InsertOrderedList 切换当前选中区是编号列表还是常规格式化块。 <BR>InsertParagraph 用换行覆盖当前选中区。 <BR>InsertSelectDropdown 用下拉框控件覆盖当前选中区。 <BR>InsertSelectListbox 用列表框控件覆盖当前选中区。 <BR>InsertTextArea 用多行文本输入控件覆盖当前选中区。 <BR>InsertUnorderedList 切换当前选中区是项目符号列表还是常规格式化块。 <BR>Italic 切换当前选中区斜体显示与否。 <BR>JustifyCenter 将当前选中区在所在格式化块置中。 <BR>JustifyFull 目前尚未支持。 <BR>JustifyLeft 将当前选中区所在格式化块左对齐。 <BR>JustifyNone 目前尚未支持。 <BR>JustifyRight 将当前选中区所在格式化块右对齐。 <BR>LiveResize 迫使 MSHTML 编辑器在缩放或移动过程中持续更新元素外观，而不是只在移动或缩放完成后更新。 <BR>MultipleSelection 允许当用户按住 Shift 或 Ctrl 键时一次选中多于一个站点可选元素。 <BR>Open 打开。 <BR>Outdent 减少选中区所在格式化块的缩进。 <BR>OverWrite 切换文本状态的插入和覆盖。 <BR>Paste 用剪贴板内容覆盖当前选中区。 <BR>PlayImage 目前尚未支持。 <BR>Print 打开打印对话框以便用户可以打印当前页。 <BR>Redo 重做。 <BR>Refresh 刷新当前文档。 <BR>RemoveFormat 从当前选中区中删除格式化标签。 <BR>RemoveParaFormat 目前尚未支持。 <BR>SaveAs 将当前 Web 页面保存为文件。 <BR>SelectAll 选中整个文档。 <BR>SizeToControl 目前尚未支持。 <BR>SizeToControlHeight 目前尚未支持。 <BR>SizeToControlWidth 目前尚未支持。 <BR>Stop 停止。 <BR>StopImage 目前尚未支持。 <BR>StrikeThrough 目前尚未支持。 <BR>Subscript 目前尚未支持。 <BR>Superscript 目前尚未支持。 <BR>UnBookmark 从当前选中区中删除全部书签。 <BR>Underline 切换当前选中区的下划线显示与否。 <BR>Undo 撤消。 <BR>Unlink 从当前选中区中删除全部超级链接。 <BR>Unselect 清除当前选中区的选中状态。 <img src ="http://www.cnitblog.com/aiut/aggbug/3422.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-20 10:50 <a href="http://www.cnitblog.com/aiut/archive/2005/10/20/3422.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>XMLHTTP 对象及其方法（转）</title><link>http://www.cnitblog.com/aiut/archive/2005/10/15/3313.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Sat, 15 Oct 2005 07:39:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/15/3313.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3313.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/15/3313.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3313.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3313.html</trackback:ping><description><![CDATA[MSXML中提供了Microsoft.XMLHTTP对象，能够完成从数据包到Request对象的转换以及发送任务。 <BR>创建XMLHTTP对象的语句如下： <BR><BR><FONT color=#0000ff>Set objXML = CreateObject(Msxml2.XMLHTTP) 或 <BR>Set objXML = CreateObject(“Microsoft.XMLHTTP”) <BR>' Or, for version 3.0 of XMLHTTP, use: <BR>' Set xml = Server.CreateObject(MSXML2.ServerXMLHTTP)</FONT> <BR><BR>对象创建后调用<FONT color=#ff1493>Open</FONT>方法对Request对象进行初始化，语法格式为： <BR>poster.open http-method, url, async, userID, password <BR><BR>Open方法中包含了5个参数，前三个是必要的，后两个是可选的(在服务器需要进行身份验证时提供)。参数的含义如下所示： <BR><FONT color=#ff0000>http-method</FONT>： HTTP的通信方式，比如GET或是 POST <BR><FONT color=#ff0000>url</FONT>： 接收XML数据的服务器的URL地址。通常在URL中要指明 ASP或CGI程序 <BR><FONT color=#ff0000>async</FONT>： 一个布尔标识，说明请求是否为异步的。如果是异步通信方式(true)，客户机就不等待服务器的响应；如果是同步方式(false)，客户机就要等到服务器返回消息后才去执行其他操作 <BR><FONT color=#ff0000>userID</FONT> 用户ID，用于服务器身份验证 <BR><FONT color=#ff0000>password</FONT> 用户密码，用于服务器身份验证&amp;nbsp; <BR><BR><BR>XMLHTTP对象的<FONT color=#ff1493>Send</FONT>方法 <BR>用Open方法对Request对象进行初始化后，调用Send方法发送XML数据： <BR>poster.send XML-data <BR><BR>Send方法的参数类型是Variant，可以是字符串、DOM树或任意数据流。发送数据的方式分为同步和异步两种。在异步方式下，数据包一旦发送完毕，就结束Send进程，客户机执行其他的操作；而在同步方式下，客户机要等到服务器返回确认消息后才结束Send进程。 <BR><BR>XMLHTTP对象中的readyState属性能够反映出服务器在处理请求时的进展状况。客户机的程序可以根据这个状态信息设置相应的事件处理方法。属性值及其含义如下表所示： <BR>值 说明 <BR>0 Response对象已经创建，但XML文档上载过程尚未结束 <BR>1 XML文档已经装载完毕 <BR>2 XML文档已经装载完毕，正在处理中 <BR>3 部分XML文档已经解析 <BR>4 文档已经解析完毕，客户端可以接受返回消息 <BR><BR>客户机处理响应信息 <BR>客户机接收到返回消息后，进行简单的处理，基本上就完成了C/S之间的一个交互周期。客户机接收响应是通过XMLHTTP对象的属性实现的： <BR>● responseTxt：将返回消息作为文本字符串； <BR>● responseXML：将返回消息视为XML文档，在服务器响应消息中含有XML数据时使用； <BR>● responseStream：将返回消息视为Stream对象。 <img src ="http://www.cnitblog.com/aiut/aggbug/3313.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-15 15:39 <a href="http://www.cnitblog.com/aiut/archive/2005/10/15/3313.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>利用XMLHTTP无刷新添加数据之Post篇(转载)</title><link>http://www.cnitblog.com/aiut/archive/2005/10/15/3312.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Sat, 15 Oct 2005 06:08:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/15/3312.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3312.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/15/3312.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3312.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3312.html</trackback:ping><description><![CDATA[<P>&nbsp;</P>
<P>我们传统的提交数据的方法都是用&lt;Form&gt;来实现的.<BR>&lt;Form&gt;标记中的Method属性确定了表单元素的数据在发送到服务器时,<BR>如何对HTTP请求信息进行打包. <BR>Method 属性可以使用的方法<BR>Method属性&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; 读取数据的Request集合<BR>Get&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 标识在URL的最后&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; QueryString<BR>Post&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在HTTP请求的主体内(HTTP请求的自由区域)&nbsp; Form</P>
<P><BR>这篇文章用XMLHTTP来实现Form的Method=Post.<BR><BR><FONT color=#ff0000>ClientPost.htm<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">language</SPAN><SPAN style="COLOR: #0000ff">="JavaScript"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;AddDataPost(sUserId,sUserName)<BR>{<BR></SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">/*</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR>&nbsp;*---------------&nbsp;AddDataPost(sUserId,sUserName)&nbsp;-----------------<BR>&nbsp;*&nbsp;AddDataPost(sUserId,sUserName)&nbsp;<BR>&nbsp;*&nbsp;功能:通过XMLHTTP添加数据.相当于Form的Method=Post.<BR>&nbsp;*&nbsp;参数:sUserId,字符串,发送条件.<BR>&nbsp;*&nbsp;参数:sUserName,字符串,发送条件.<BR>&nbsp;*&nbsp;实例:AddDataPost(document.all.userid.value,document.all.username.value);<BR>&nbsp;*---------------&nbsp;AddDataPost(sUserId,sUserName)&nbsp;-----------------<BR>&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">*/</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;oBao&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ActiveXObject(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Microsoft.XMLHTTP</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">特殊字符：+,%,&amp;,=,?等的传输解决办法.</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">Update:2004-6-1&nbsp;12:22</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">escape(sUserId),escape(sUserName);</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;sUserId&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;escape(sUserId);<BR>&nbsp;&nbsp;&nbsp;&nbsp;sUserName&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;escape(sUserName);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;userInfo&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">userid=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">sUserId</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;username=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">sUserName;<BR>&nbsp;&nbsp;&nbsp;&nbsp;oBao.open(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">POST</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Server.asp</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">false</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;oBao.setRequestHeader(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Content-Type</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">application/x-www-form-urlencoded</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)<BR>&nbsp;&nbsp;&nbsp;&nbsp;oBao.send(userInfo);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">清空输入框数据.</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;document.all.userid.value</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">""</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;document.all.username.value</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">""</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">服务器端处理返回的是经过escape编码的字符串.</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;alert(unescape(oBao.responseText))<BR>}<BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="button"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;onclick</SPAN><SPAN style="COLOR: #0000ff">="AddDataPost(document.all.userid.value,document.all.username.value)"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="AddDataPost"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;</SPAN><SPAN style="COLOR: #800000">br</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>userid:</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="text"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;name</SPAN><SPAN style="COLOR: #0000ff">="userid"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;</SPAN><SPAN style="COLOR: #800000">br</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>username:</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="text"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;name</SPAN><SPAN style="COLOR: #0000ff">="username"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV></FONT><BR><FONT color=#ff0000>Server.asp&nbsp; 服务器端处理.<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">&lt;%</SPAN><SPAN style="COLOR: #000000">&nbsp;@Language</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">JavaScript</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #000000">&lt;%</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;OpenDB(sdbname)<BR>{<BR></SPAN><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000"><BR>&nbsp;*---------------&nbsp;OpenDB(sdbname)&nbsp;-----------------<BR>&nbsp;*&nbsp;OpenDB(sdbname)&nbsp;<BR>&nbsp;*&nbsp;功能:打开数据库sdbname,返回conn对象.<BR>&nbsp;*&nbsp;参数:sdbname,字符串,数据库名称.<BR>&nbsp;*&nbsp;实例:var&nbsp;conn&nbsp;=&nbsp;OpenDB("database.mdb");<BR>&nbsp;*---------------&nbsp;OpenDB(sdbname)&nbsp;-----------------<BR>&nbsp;</SPAN><SPAN style="COLOR: #008000">*/</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;connstr&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Provider=Microsoft.Jet.OLEDB.4.0;&nbsp;Data&nbsp;Source=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">Server.MapPath(sdbname);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;conn&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Server.CreateObject(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ADODB.Connection</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;conn.Open(connstr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;conn;<BR>}<BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;sResult&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;oConn&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;OpenDB(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">data.mdb</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">相当于Form的Method=Post.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">相当于Form的Method=Post.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">特殊字符：+,%,&amp;,=,?等的传输解决办法.客户端传输过来是经过escape编码的.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">所以服用器端应该先unescape解码.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">Update:2004-6-1&nbsp;12:22</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">unescape(Request.Form("userid"))<IMG src="http://www.cnitblog.com/images/dot.gif">..</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;userid&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;unescape(Request.Form(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">userid</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));<BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;username&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;unescape(Request.Form(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">username</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));<BR>sResult&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">userid:</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">userid</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\nusername:</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">username</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\n&nbsp;添加成功.</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;sql&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Insert&nbsp;into&nbsp;users(userid,username)Values('</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">userid</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">','</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">username</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">')</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR>oConn.Execute(sql);<BR>Response.Write(escape(sResult));<BR></SPAN><SPAN style="COLOR: #000000">%&gt;</SPAN></DIV>
<P></FONT><FONT color=#000000>数据库设计<BR>data.mdb<BR>表users.<BR>字段<BR>id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 自动编号<BR>userid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 文本<BR>username&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 文本</FONT></P>
<P><FONT color=#000000>表:users 数据: <BR>id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; userid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username<BR>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wanghr100&nbsp;&nbsp; 管理员</FONT></P><img src ="http://www.cnitblog.com/aiut/aggbug/3312.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-15 14:08 <a href="http://www.cnitblog.com/aiut/archive/2005/10/15/3312.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>