﻿<?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-笑着生活</title><link>http://www.blogjava.net/yzzh9/</link><description>思想大于技术......
惟仁者为能以大事小,惟智者为能以小事大：
Java之路——专注，研究，思考，总结
</description><language>zh-cn</language><lastBuildDate>Tue, 12 May 2026 10:24:32 GMT</lastBuildDate><pubDate>Tue, 12 May 2026 10:24:32 GMT</pubDate><ttl>60</ttl><item><title>[导入]IO流（1）</title><link>http://www.blogjava.net/yzzh9/archive/2009/06/09/280916.html</link><dc:creator>999</dc:creator><author>999</author><pubDate>Tue, 09 Jun 2009 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/yzzh9/archive/2009/06/09/280916.html</guid><wfw:comment>http://www.blogjava.net/yzzh9/comments/280916.html</wfw:comment><comments>http://www.blogjava.net/yzzh9/archive/2009/06/09/280916.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yzzh9/comments/commentRss/280916.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yzzh9/services/trackbacks/280916.html</trackback:ping><description><![CDATA[<div class=MsoNormal style="margin: 0cm 0cm 0pt 84pt; text-indent: -84pt; mso-char-indent-count: -8.0"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>输入流和输出流：往程序中读入的流就是输入流（</span><span lang=EN-US>InputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>和</span><span lang=EN-US>Reader</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>的子类），从程序写出到其他介质的流就是输出流（</span><span lang=EN-US>OutputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>和</span><span lang=EN-US>Writer</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>的子类）。</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 84pt; text-indent: -84pt; mso-char-indent-count: -8.0"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>节点流和处理流：节点流为直接操作外部介质的类如</span><span lang=EN-US>FileOutputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，</span><span lang=EN-US>FileInputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，</span><span lang=EN-US>FileWriter</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，</span><span lang=EN-US>FileReader</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>等。处理流为套接在节点流上的流如缓冲流</span><span lang=EN-US>BufferedInputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，</span><span lang=EN-US style="color: red">BufferReader</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，数据流</span><span lang=EN-US>DateInputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，</span><span lang=EN-US>DateOutputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，转换流</span><span lang=EN-US>InputStreamReader</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>。</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>字节流和字符流：以</span><span lang=EN-US>stream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>结尾的都为字节流。</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>范围：</span><span lang=EN-US>ascll</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>：</span><span lang=EN-US>0-126<span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>unicode</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>：</span><span lang=EN-US>0-65535</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>原来很多国家和地区都有自己的编码：</span><span lang=EN-US>gbk</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，</span><span lang=EN-US>gb2312</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>等，不统一。</span><span lang=EN-US>Unicode</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>则统一了全世界文字的编码，一个字符占两个字节。</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span lang=EN-US style="color: red">java</span><span style="color: red; font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>中用的是</span><span lang=EN-US style="color: red">unicode</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，一个字符占两个字节，</span><span lang=EN-US>16</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>位</span><span lang=EN-US>.</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span lang=EN-US>char</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>（字符）类型使用国际通用的</span><span lang=EN-US>16</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>位</span><span lang=EN-US>Unicode</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>字符集，所以能自动表达大多数国家的字符。</span><span lang=EN-US><span style="mso-spacerun: yes">&nbsp;&nbsp; </span></span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span lang=EN-US>String </span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>字串里的每个字符都是</span><span lang=EN-US>16</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>位，或者说</span><span lang=EN-US>2</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>个字节、长整数，以便提供对</span><span lang=EN-US>Unicode</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>字符的支持。</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span lang=EN-US>Java</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>所提供的所有流类型位于包</span><span lang=EN-US>java.io</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>内，且都分别继承自以下四种抽象流类型。</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?><img onclick='window.open(this.src)' onclick=window.open(this.src) alt="" src="http://java999.blog.51cto.com/attachment/200905/200905211242902097390.jpg" border="0" /></span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><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></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?><font size="3">简单理解这四个抽象类就是：写出，读入（写出，读入都是以程序为参考物的）</font></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>区别：</span><span lang=EN-US>InputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>的</span><span lang=EN-US>int read</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>（）方法的返回值范围为</span><span lang=EN-US>0-255</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>（字节）</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt; mso-outline-level: 1"><font size="3"><span lang=EN-US><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Reader</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>的</span><span lang=EN-US>int read</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>（）方法的返回值范围为</span><span lang=EN-US>0-65535</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>（字符）</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span lang=EN-US><span style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes">&nbsp; </span>OutputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>和</span><span lang=EN-US>Writer</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>的</span><span lang=EN-US>write</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>（）方法的区别看</span><span lang=EN-US>API</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，写得很详细。</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>下面分别介绍这四个抽象类：</span> </font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 57.75pt; text-indent: -57.75pt; mso-char-indent-count: -5.5"><font size="3"><span lang=EN-US>InputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>：继承自</span><span lang=EN-US>InputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>的流都是用于向程序中输入数据，且数据的单位为字节（</span><span lang=EN-US>8bit</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>）</span><span lang=EN-US>[</span><span style="color: red; font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>这些类中的</span><span lang=EN-US style="color: red">read</span><span style="color: red; font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>（）方法获取的都是</span><span lang=EN-US style="color: red">unicode</span><span style="color: red; font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>码（两字节，</span><span lang=EN-US style="color: red">16</span><span style="color: red; font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>位）</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，因此对于</span><span lang=EN-US>ascll</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>码中的字符可以正确读取，因为他们的</span><span lang=EN-US>unicode</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>码和</span><span lang=EN-US>ascll </span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>码是一样的（</span><span lang=EN-US>unicode</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>码前一个字节为</span><span lang=EN-US>0</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，后一个字节则为相应的</span><span lang=EN-US>ascll</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>码）。但是不能读取汉字，因为汉字的</span><span lang=EN-US>unicode</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>码大于</span><span lang=EN-US>256</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>，占两个字节</span><span lang=EN-US>].</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><o:p><font size="3"><img onclick='window.open(this.src)' onclick=window.open(this.src) alt="" src="http://java999.blog.51cto.com/attachment/200905/200905211242902116468.jpg" border="0" />&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><font size="3"><span lang=EN-US>OutputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>：继承自</span><span lang=EN-US>OutputStream</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>的流都是用于向程序中输出数据，且数据的单位为字节（</span><span lang=EN-US>8bit</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>）</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><span lang=EN-US></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><span lang=EN-US><o:p><font size="3"><img onclick='window.open(this.src)' onclick=window.open(this.src) alt="" src="http://java999.blog.51cto.com/attachment/200905/200905211242902132843.jpg" border="0" />&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><font size="3"><span lang=EN-US>Reader</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>：继承自</span><span lang=EN-US>Reader</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>的流都是用于向程序中输入数据，且数据的单位为字符（</span><span lang=EN-US>16bit</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>）</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><span lang=EN-US></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><span lang=EN-US><o:p><font size="3"><img onclick='window.open(this.src)' onclick=window.open(this.src) alt="" src="http://java999.blog.51cto.com/attachment/200905/200905211242902146140.jpg" border="0" />&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><span lang=EN-US><o:p><font size="3">&nbsp;</font></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><font size="3"><span lang=EN-US>Writer</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>：继承自</span><span lang=EN-US>Writer</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>的流都是用于程序中输出数据，且数据的单位为字符（</span><span lang=EN-US>16bit</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>）</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?><img onclick='window.open(this.src)' onclick=window.open(this.src) alt="" src="http://java999.blog.51cto.com/attachment/200905/200905211242902165984.jpg" border="0" /></span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><span lang=EN-US></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 63pt; text-indent: -63pt; mso-char-indent-count: -6.0"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>以上为对</span><span lang=EN-US>IO</span><span style="font-family: 宋体; mso-ascii-font-family: " Times Roman?; mso-hansi-font-family: ?Times New Roman?>的总体概述，后续会写出一些类的例子。</span></font></div><br>文章来源:<a href='http://java999.blog.51cto.com/259217/159843'>http://java999.blog.51cto.com/259217/159843</a><img src ="http://www.blogjava.net/yzzh9/aggbug/280916.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yzzh9/" target="_blank">999</a> 2009-06-09 13:41 <a href="http://www.blogjava.net/yzzh9/archive/2009/06/09/280916.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]IO流（2）</title><link>http://www.blogjava.net/yzzh9/archive/2009/06/09/280915.html</link><dc:creator>999</dc:creator><author>999</author><pubDate>Tue, 09 Jun 2009 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/yzzh9/archive/2009/06/09/280915.html</guid><wfw:comment>http://www.blogjava.net/yzzh9/comments/280915.html</wfw:comment><comments>http://www.blogjava.net/yzzh9/archive/2009/06/09/280915.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yzzh9/comments/commentRss/280915.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yzzh9/services/trackbacks/280915.html</trackback:ping><description><![CDATA[<div><font color="#ff0000">ByteArrayToDataStream.java</font></div>
<div>
<div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><font color="#0000ff">public</font> <font color="#0000ff">class</font> ByteArrayToDataStream { <br /><br />&nbsp;&nbsp;<font color="#0000ff">public</font> <font color="#0000ff">static</font> <font color="#0000ff">void</font> main(String[] args) { <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">// 节点流（节点对象为字节数组） </font><br />&nbsp;&nbsp;&nbsp;&nbsp;ByteArrayOutputStream baos = <font color="#0000ff">new</font> ByteArrayOutputStream(); <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">//数据处理流，套接在字节数组节点流上。方便写数据 </font><br />&nbsp;&nbsp;&nbsp;&nbsp;DataOutputStream dos = <font color="#0000ff">new</font> DataOutputStream(baos); <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">try</font> { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">//由于套接了数据处理流，所以可以直接写long，double类型数据 </font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dos.writeLong(999999999999999L); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dos.writeDouble(Math.random()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ByteArrayInputStream bais = <font color="#0000ff">new</font> ByteArrayInputStream(baos <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.toByteArray()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">//数据处理流，套接在字节数组节点流上。方便读数据 </font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DataInputStream dis = <font color="#0000ff">new</font> DataInputStream(bais); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(dis.readLong()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(dis.readDouble()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dos.close(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dis.close(); <br />&nbsp;&nbsp;&nbsp;&nbsp;} <font color="#0000ff">catch</font> (IOException e) { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace(); <br />&nbsp;&nbsp;&nbsp;&nbsp;} <br />&nbsp;&nbsp;} <br />} <br /></div></div>
<div>&nbsp;</div>
<div><font color="#ff0000">TestBufferedReader.java</font></div>
<div>
<div>
<div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><font color="#008000">/** <br />* Title:TestBufferedReader.java&nbsp;&nbsp;&nbsp;&nbsp;<br />* Description:BufferedReader为处理缓冲流，其中的readline（） <br />*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 方法很好用，经常套接在别的节点流上使用。 <br />* <br />* @author winwin&nbsp;&nbsp;&nbsp;&nbsp;<br />* @version 1.0&nbsp;&nbsp;&nbsp;&nbsp;<br />* @since May 20, 20092:55:21 PM&nbsp;&nbsp;&nbsp;&nbsp;<br />*/</font> <br /><font color="#0000ff">public</font> <font color="#0000ff">class</font> TestBufferedReader { <br /><br />&nbsp;&nbsp;<font color="#0000ff">public</font> <font color="#0000ff">static</font> <font color="#0000ff">void</font> main(String[] args) { <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">try</font> { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">//创建一个文件节点输入流 </font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FileReader fr = <font color="#0000ff">new</font> FileReader(<font color="#800000">"d:\\test.txt"</font>); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">//创建一个处理缓冲流 </font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BufferedReader br = <font color="#0000ff">new</font> BufferedReader(fr); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String string = <font color="#0000ff">null</font>; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">while</font>((string=br.readLine())!=<font color="#0000ff">null</font>){ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(string); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br />&nbsp;&nbsp;&nbsp;&nbsp;} <font color="#0000ff">catch</font> (FileNotFoundException e) { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace(); <br />&nbsp;&nbsp;&nbsp;&nbsp;} <font color="#0000ff">catch</font> (IOException e) { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace(); <br />&nbsp;&nbsp;&nbsp;&nbsp;} <br />&nbsp;&nbsp;} <br />}</div></div>
<div>&nbsp;</div>
<div><font color="#ff0000">TestByteArryStream.java</font></div>
<div>
<div>
<div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><font color="#0000ff">public</font> <font color="#0000ff">class</font> TestByteArryStream { <br /><br />&nbsp;&nbsp;<font color="#0000ff">public</font> <font color="#0000ff">static</font> <font color="#0000ff">void</font> main(String[] args) { <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">//节点流，节点为字符数组，存储在内存中 </font><br />&nbsp;&nbsp;&nbsp;&nbsp;ByteArrayOutputStream bos = <font color="#0000ff">new</font> ByteArrayOutputStream(); <br />&nbsp;&nbsp;&nbsp;&nbsp;ByteArrayInputStream bis = <font color="#0000ff">null</font>; <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">int</font> a = 0; <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">byte</font>[] bytes = {'a','b','c','1','2','3'}; <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">try</font> { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bos.write(bytes); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bis = <font color="#0000ff">new</font> ByteArrayInputStream(bos.toByteArray()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">while</font>((a = bis.read())!=-1){ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print((<font color="#0000ff">char</font>)a); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bos.close(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bis.close(); <br />&nbsp;&nbsp;&nbsp;&nbsp;} <font color="#0000ff">catch</font> (IOException e) { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace(); <br />&nbsp;&nbsp;&nbsp;&nbsp;} <br />&nbsp;&nbsp;} <br /><br />}</div></div></div>
<div>&nbsp;</div>
<div><font color="#ff0000">TestFileInputStream.java</font></div>
<div>
<div>
<div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee">
<div><font color="#0000ff">/**<br />&nbsp;* Title:TestFileInputStream.java <br />&nbsp;* Description:FileInputStream为输入流，字节流，节点流（操作的节点为文件），<br />&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 通过此流可以读取文件中的内容到程序中，但由于是字节流，将不能正确<br />&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 读取中文。<br />&nbsp;* @author winwin <br />&nbsp;* @version 1.0 <br />&nbsp;* @since May 20, 200911:12:45 AM <br />&nbsp;*/</font></div>
<div><font color="#0000ff"></font>&nbsp;</div>
<div><font color="#0000ff">public</font> <font color="#0000ff">class</font> TestFileInputStream { <br /><br />&nbsp;&nbsp;<font color="#0000ff">public</font> <font color="#0000ff">static</font> <font color="#0000ff">void</font> main(String[] args) { <br />&nbsp;&nbsp;&nbsp;&nbsp;FileInputStream fileInputStream = <font color="#0000ff">null</font>; <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">int</font> read; <br />&nbsp;&nbsp;&nbsp;&nbsp;String string = <font color="#800000">"D:\\test.txt"</font>; <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">try</font> { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">//在文件上创建输入流 </font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fileInputStream = <font color="#0000ff">new</font> FileInputStream(string); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">//按字节读取文件，直至结尾（-1）,不能读取中文 </font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">while</font>((read=fileInputStream.read())!=-1){ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print((<font color="#0000ff">char</font>)read); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fileInputStream.close(); <br />&nbsp;&nbsp;&nbsp;&nbsp;} <font color="#0000ff">catch</font> (FileNotFoundException e) { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace(); <br />&nbsp;&nbsp;&nbsp;&nbsp;} <font color="#0000ff">catch</font> (IOException e) { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace(); <br />&nbsp;&nbsp;&nbsp;&nbsp;} <br />&nbsp;&nbsp;} <br />} <br /></div></div></div></div></div><br>文章来源:<a href='http://java999.blog.51cto.com/259217/160015'>http://java999.blog.51cto.com/259217/160015</a><img src ="http://www.blogjava.net/yzzh9/aggbug/280915.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yzzh9/" target="_blank">999</a> 2009-06-09 13:41 <a href="http://www.blogjava.net/yzzh9/archive/2009/06/09/280915.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]有计划，多复习</title><link>http://www.blogjava.net/yzzh9/archive/2009/06/09/280914.html</link><dc:creator>999</dc:creator><author>999</author><pubDate>Tue, 09 Jun 2009 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/yzzh9/archive/2009/06/09/280914.html</guid><wfw:comment>http://www.blogjava.net/yzzh9/comments/280914.html</wfw:comment><comments>http://www.blogjava.net/yzzh9/archive/2009/06/09/280914.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yzzh9/comments/commentRss/280914.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yzzh9/services/trackbacks/280914.html</trackback:ping><description><![CDATA[<div class=MsoNormal style="margin: 0cm 0cm 0pt"><font size="3"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体; mso-ascii-font-family: "Times New Roman'; mso-hansi-font-family: 'Times New Roman'">计划很重要，复习也很重要。有了计划做事情将不会浮躁；学会经常复习，将会提高效率。</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt; text-indent: 21.75pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: "Times New Roman'; mso-hansi-font-family: 'Times New Roman'">做一件事情如果有计划地去做，将会顺风顺雨；如果没有计划去做一件事情，运气好的话可能很快就做好，运气不好的话你费尽心思也毫无头绪，好像始终在起点上。比如我们学习一门新技术，不能一上来就从头至尾啃，这样的话今天你学过的东西，明天可能就忘记了。我们应该先看看这门技术有什么流程图或原理图之类按照去学习，或者先看看这门技术有什么用途，根据用途去看它是怎么实现的，这样就比较有针对性，学习起来也会事半功倍。再比如对于程序中的错误，我们就应该有计划的从错误的日志开始去程序中找</span><span lang=EN-US>bug</span><span style="font-family: 宋体; mso-ascii-font-family: "Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所在，而不要想当然的去读程序找</span><span lang=EN-US>bug</span><span style="font-family: 宋体; mso-ascii-font-family: "Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span></font></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt; 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'"><font size="3">对于学过的知识如果及时去复习，将会提高很多效率。就像我们写在博客上的技术文章，如果不及时复习，也会很快忘记的。所以有事没事多复习吧。</font></span></div><br>文章来源:<a href='http://java999.blog.51cto.com/259217/162456'>http://java999.blog.51cto.com/259217/162456</a><img src ="http://www.blogjava.net/yzzh9/aggbug/280914.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yzzh9/" target="_blank">999</a> 2009-06-09 13:41 <a href="http://www.blogjava.net/yzzh9/archive/2009/06/09/280914.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]java中的值传递和引用传递</title><link>http://www.blogjava.net/yzzh9/archive/2009/06/09/280913.html</link><dc:creator>999</dc:creator><author>999</author><pubDate>Tue, 09 Jun 2009 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/yzzh9/archive/2009/06/09/280913.html</guid><wfw:comment>http://www.blogjava.net/yzzh9/comments/280913.html</wfw:comment><comments>http://www.blogjava.net/yzzh9/archive/2009/06/09/280913.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yzzh9/comments/commentRss/280913.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yzzh9/services/trackbacks/280913.html</trackback:ping><description><![CDATA[<div><font style="background-color: #ffffff" color="#8b0000">此篇文章为转载，原文地址不详，红色部分为我添加的注解。</font></div>
<div><font color="#8b0000"></font>&nbsp;</div>
<div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">值传递：方法调用时，实际参数把它的值传递给对应的形式参数，方法执行中形式参数值的改变不影响实际参</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">&nbsp;</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">数的值。</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br /></span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">引用传递：也称为传地址。方法调用时，实际参数的引用</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">(</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">地址，而不是参数的值</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">)</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">被传递给方法中相对应的形式参数，在方法执行中，对形式参数的操作实际上就是对实际参数的操作，方法执行中形式参数值的改变将会影响实际参数的值。</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><o:p>&nbsp;</o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US style="font-size: 10pt; color: red; font-family: georgia">Java</span><span style="font-size: 10pt; color: red; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">中的基本数据类型作为参数都是值传递，另外还要注意基本数据类型的包装类作为函数参数时也是值传递。（至于</span><span lang=EN-US style="font-size: 10pt; color: red; font-family: georgia">String</span><span style="font-size: 10pt; color: red; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">和</span><span lang=EN-US style="font-size: 10pt; color: red; font-family: georgia">StringBuilder</span><span style="font-size: 10pt; color: red; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">作为参数时传递的是引用，但由于</span><span lang=EN-US style="font-size: 10pt; color: red; font-family: georgia">String</span><span style="font-size: 10pt; color: red; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">类里没有提供方法改变它的值，所以不能改变它的值，</span><span lang=EN-US style="font-size: 10pt; color: red; font-family: georgia">StringBuilder</span><span style="font-size: 10pt; color: red; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">可以通过</span><span lang=EN-US style="font-size: 10pt; color: red; font-family: georgia">append</span><span style="font-size: 10pt; color: red; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">（）方法改变它的值。具体的例子请参加这篇文章：<a href="http://java999.blog.51cto.com/259217/162739">http://java999.blog.51cto.com/259217/162739</a>）</span><span lang=EN-US style="font-size: 10pt; color: red; font-family: georgia"><o:p></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt; color: red; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">对象作为函数参数时是引用传递，</span><span style="font-size: 10pt; color: red; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia; mso-bidi-font-size: 9.0pt">对象可以是</span><span lang=EN-US style="font-size: 10pt; color: red; font-family: georgia; mso-bidi-font-size: 9.0pt">JAVA</span><span style="font-size: 10pt; color: red; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia; mso-bidi-font-size: 9.0pt">中的非简单数据类型对象，也可以是自定义对象。</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><o:p></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br /></span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">下面举例说明：</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br /></span><em><b><span style="font-size: 10pt; color: #ff6600; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">传值</span></b></em><em><b><span lang=EN-US style="font-size: 10pt; color: #ff6600; font-family: georgia">---</span></b></em><em><b><span style="font-size: 10pt; color: #ff6600; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">传递基本数据类型参数</span></b></em><b><i><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br /></span></i></b><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">public&nbsp;&nbsp;&nbsp;&nbsp;class&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PassValue{<br />&nbsp;&nbsp;&nbsp;&nbsp;static void exchange(int a, int b){//</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">静态方法，交换</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">a,b</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">的值</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int temp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp = a;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a = b;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b = temp;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String[] args){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int i = 10;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int j = 100;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("before call: " + "i=" + i + "\t" + "j = " + j);//</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">调用前</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exchange(i, j);&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;&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 style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">值传递，</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">main</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">方法只能调用静态方法</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("after call: " + "i=" + i + "\t" + "j = " + j);//</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">调用后</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">运行结果：</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;before call: i = 10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j = 100<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;after&nbsp;&nbsp;&nbsp;&nbsp;call: i = 10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j = 100<br /></span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">说明：调用</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">exchange(i, j)</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">时，实际参数</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">i</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">，</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">j</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">分别把值传递给相应的形式参数</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">a</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">，</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">b,</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">在执行方法</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">exchange()</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">时，形式参数</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">a</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">，</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">b</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">的值的改变不影响实际参数</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">i</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">和</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">j</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">的值，</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">i</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">和</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">j</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">的值在调用前后并没改变。</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br /></span><em><b><span style="font-size: 10pt; color: #ff6600; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">引用传递</span></b></em><em><b><span lang=EN-US style="font-size: 10pt; color: #ff6600; font-family: georgia">---</span></b></em><em><b><span style="font-size: 10pt; color: #ff6600; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">对象作为参数</span></b></em><b><i><span lang=EN-US style="font-size: 10pt; color: #ff6600; font-family: georgia"><br /></span></i></b><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">如果在方法中把对象（或数组）作为参数，方法调用时，参数传递的是对象的引用（地址），即在方法调用时，实际参数把对对象的引用（地址）传递给形式参数。这是实际参数与形式参数指向同一个地址，即同一个对象（数组），方法执行时，对形式参数的改变实际上就是对实际参数的改变，这个结果在调用结束后被保留了下来。</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />class Book{<br />&nbsp;&nbsp;&nbsp;&nbsp;String name;<br />&nbsp;&nbsp;&nbsp;&nbsp;private folat price;<br />&nbsp;&nbsp;&nbsp;&nbsp;Book(String n,&nbsp;&nbsp;&nbsp;&nbsp;float ){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">构造方法</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name = n;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;price = p;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;&nbsp;void&nbsp; change(Book a_book,&nbsp;&nbsp;&nbsp;&nbsp;String n,&nbsp;&nbsp;&nbsp;&nbsp;float p){&nbsp;&nbsp;&nbsp;&nbsp;//</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">静态方法，对象作为参数</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a_book.name = n;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a_book.price = p;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;public void output(){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">实例方法，输出对象信息</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("name: " + name + "\t" + "price: " + price);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br />&nbsp;public class PassAddr{<br />&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String [] args){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Book b = new Book("java2",&nbsp;&nbsp;&nbsp;&nbsp;<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="32.5" UnitName="F">32.5f</st1:chmetcnv>);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print("before call:\t");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">调用前</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b.output();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b.change(b,&nbsp;&nbsp;&nbsp;&nbsp;"c++",&nbsp;&nbsp;&nbsp;&nbsp;<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="45.5" UnitName="F">45.5f</st1:chmetcnv>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">引用传递，传递对象</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">b</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">的引用，修改对象</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">b</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">的值</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print("after call:\t");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">调用后</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b.output();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">运行结果：</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;before&nbsp;&nbsp;&nbsp;&nbsp;call:&nbsp;&nbsp;&nbsp;&nbsp;name:java2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;price:32.5<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;after&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call:&nbsp;&nbsp;&nbsp;&nbsp;name:c++&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;price:45.5<br /></span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">说明：调用</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">change(b,"c++",<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="45.5" UnitName="F">45.5f</st1:chmetcnv>)</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">时，对象</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">b</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">作为实际参数，把引用传递给相应的形式参数</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">a_book,</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">实际上</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">a_book</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">也指向同一个对象，即该对象有两个引用名：</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">b</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">和</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">a_book</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">。在执行方法</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">change()</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">时，对形式参数</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">a_book</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">操作就是对实际参数</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia">b</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">的操作。</span></div></div><br>文章来源:<a href='http://java999.blog.51cto.com/259217/162732'>http://java999.blog.51cto.com/259217/162732</a><img src ="http://www.blogjava.net/yzzh9/aggbug/280913.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yzzh9/" target="_blank">999</a> 2009-06-09 13:41 <a href="http://www.blogjava.net/yzzh9/archive/2009/06/09/280913.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]String和StringBuilder区别</title><link>http://www.blogjava.net/yzzh9/archive/2009/06/09/280912.html</link><dc:creator>999</dc:creator><author>999</author><pubDate>Tue, 09 Jun 2009 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/yzzh9/archive/2009/06/09/280912.html</guid><wfw:comment>http://www.blogjava.net/yzzh9/comments/280912.html</wfw:comment><comments>http://www.blogjava.net/yzzh9/archive/2009/06/09/280912.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yzzh9/comments/commentRss/280912.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yzzh9/services/trackbacks/280912.html</trackback:ping><description><![CDATA[<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">string</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>的</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">“+”</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>操作就是根据</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">StringBuilder</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>（或</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt"> StringBuffer</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>）类及其</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt"> append </span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>方法实现的。</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>String</span></strong><strong><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>不可变其实就是说一个</span></strong><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>String</span></strong><strong><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>对象创建之后不能再在这个对象上做其他操作（如追加，删除一个字符），只能通过创建别的</span></strong><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>String</span></strong><strong><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>对象来获取这个效果，而</span></strong><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>StringBuilder</span></strong><strong><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>就可以在一个</span></strong><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>StringBuilder</span></strong><strong><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>对象上进行改变：</span></strong><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times><o:p></o:p></span></strong></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">String<span style="mso-spacerun: yes">&nbsp; </span>str = </span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">“</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">hello</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">”</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>；</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt"><o:p></o:p></span></strong></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 131.1pt; text-indent: -131.1pt; mso-char-indent-count: -13.11"><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">str = str+</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">“</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>，</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">world</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>！</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">”</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>；</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">//</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>这时并不是在原来的</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">“</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">hello</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">”对象</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>上追加</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">“</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>，</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">world</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>！</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">”</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>，而是重新创建了一个</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">“</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">hello</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>，</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">world</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>！</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">”对象</span></strong><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times><o:p></o:p></span></strong></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt"><o:p>&nbsp;</o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">String </span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>不能被修改，事实上很简单。就是因为</span><span style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt"> <strong><span lang=EN-US style="font-family: georgia">String </span></strong></span><strong><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>没有提供写操作方法，没有提供能够修改</span></strong><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">String</span></strong><strong><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>对象的成员变量的方法。而</span></strong><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>StringBuilder</span></strong><strong><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>则提供了这样的方法（</span></strong><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>append</span></strong><strong><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>（）等方法）。</span></strong><strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times><o:p></o:p></span></strong></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt"><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">也许有人会说</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">String</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">不是有个</span></strong><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">concat</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">方法可以在字符串后面追加字符串吗？呵呵，我们看过</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">API</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia">的解释就知道是怎么回事了：</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt"><o:p></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt; text-align: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-outline-level: 3" align="left"><b><span lang=EN-US style="font-size: 13.5pt; font-family: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Concat<o:p></o:p></span></b></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt; text-align: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-outline-level: 3" align="left"><span lang=EN-US style="font-size: 12pt; font-family: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">public <a title="java.lang" href="http://blog.51cto.com/j2se%20j2ee%20API/html/zh_CN/api/java/lang/String.html" 中的类>String</a> <b>concat</b>(<a title="java.lang" href="http://blog.51cto.com/j2se%20j2ee%20API/html/zh_CN/api/java/lang/String.html" 中的类>String</a>&nbsp;str)<o:p></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 36pt; text-align: left; mso-pagination: widow-orphan" align="left"><span style="font-size: 12pt; font-family: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">将指定字符串联到此字符串的结尾。<span lang=EN-US> <o:p></o:p></span></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt 36pt; text-align: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left"><span style="font-size: 12pt; font-family: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">如果参数字符串的长度为<span lang=EN-US> 0</span>，则返回此<span lang=EN-US> String </span>对象。否则，创建一个新的<span lang=EN-US> String </span>对象，用来表示由此<span lang=EN-US> String </span>对象表示的字符序列和由参数字符串表示的字符序列串联而成的字符序列。<span lang=EN-US><o:p></o:p></span></span></div>
<div><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " mso-bidi-font-size: Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: 1.0pt; mso-font-kerning: 12.0pt;>对了，区别就在于</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-fareast-font-family: 宋体; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa">String</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " mso-bidi-font-size: Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: 1.0pt; mso-font-kerning: 12.0pt;>的调用</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-fareast-font-family: 宋体; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa">concat</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " mso-bidi-font-size: Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: 1.0pt; mso-font-kerning: 12.0pt;>方法会新建立一个</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-fareast-font-family: 宋体; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa">String</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " mso-bidi-font-size: Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: 1.0pt; mso-font-kerning: 12.0pt;>对象，而</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-fareast-font-family: 宋体; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa">StringBuilder</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " mso-bidi-font-size: Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: 1.0pt; mso-font-kerning: 12.0pt;>的</span></strong><strong><span lang=EN-US style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-fareast-font-family: 宋体; mso-ansi-language: en-us; mso-fareast-language: zh-cn; mso-bidi-language: ar-sa">append</span></strong><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " mso-bidi-font-size: Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: 1.0pt; mso-font-kerning: 12.0pt;>方法返回的还是原来对象的应用。</span></strong></div><strong><span style="font-weight: normal; font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " mso-bidi-font-size: Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: 1.0pt; mso-font-kerning: 12.0pt;>
<div>
<div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><font color="#0000ff">public</font> <font color="#0000ff">class</font> TestValue { <br />&nbsp;&nbsp;<font color="#0000ff">public</font> <font color="#0000ff">static</font> <font color="#0000ff">void</font> main(String[] args) { <br />&nbsp;&nbsp;&nbsp;&nbsp;String string = <font color="#0000ff">new</font> String(<font color="#800000">"Hello"</font>); <br />&nbsp;&nbsp;&nbsp;&nbsp;modify(string); <br />&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(string); <br />&nbsp;&nbsp;} <br />&nbsp;&nbsp;<font color="#0000ff">public</font> <font color="#0000ff">static</font> <font color="#0000ff">void</font> modify(String s) { <br />&nbsp;&nbsp;&nbsp;&nbsp;s += <font color="#800000">"world!"</font>;<font color="#008000">//这里通过"+"操作创建了一个新对象让s指向它。但string的引用并没有变。 </font><br />&nbsp;&nbsp;&nbsp;&nbsp;s = s.concat(<font color="#800000">"winwin"</font>);<font color="#008000">//这里的concat方法重新创建了一个String对象，所以string的引用没有变，只是s的引用变了。 </font><br />&nbsp;&nbsp;} <br />} <br /></div></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>
<div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><font color="#0000ff">public</font> <font color="#0000ff">class</font> TestValue { <br />&nbsp;&nbsp;<font color="#0000ff">public</font> <font color="#0000ff">static</font> <font color="#0000ff">void</font> main(String[] args) { <br />&nbsp;&nbsp;&nbsp;&nbsp;StringBuilder string = <font color="#0000ff">new</font> StringBuilder(<font color="#800000">"Hello"</font>); <br />&nbsp;&nbsp;&nbsp;&nbsp;modify(string); <br />&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(string); <br />&nbsp;&nbsp;} <br />&nbsp;&nbsp;<font color="#0000ff">public</font> <font color="#0000ff">static</font> <font color="#0000ff">void</font> modify(StringBuilder s) { <br />&nbsp;&nbsp;&nbsp;&nbsp;s.append(<font color="#800000">",world!"</font>);<font color="#008000">//由于StringBuilder类有方法可以改变，所以就能够改变string的值。 </font><br />&nbsp;&nbsp;} <br />} <br /></div></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none" align="left"><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " New?? ?Courier mso-bidi-font-family: New?; Courier>此篇文章为我自己写的笔记，既然是笔记，顺便再写一点与题目无关的内容：</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-family: " New?? Courier><o:p></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none" align="left"><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-family: " New?? Courier>String str = </span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia; mso-bidi-font-family: " New?? Courier>“</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-family: " New?? Courier>winwin</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia; mso-bidi-font-family: " New?? Courier>”</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " New?? ?Courier mso-bidi-font-family: New?; Courier>；</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-family: " New?? Courier><o:p></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none" align="left"><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-family: " New?? Courier>String str = new String(</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia; mso-bidi-font-family: " New?? Courier>“</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-family: " New?? Courier>winwin</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: georgia; mso-bidi-font-family: " New?? Courier>”</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-family: " New?? Courier>)</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " New?? ?Courier mso-bidi-font-family: New?; Courier>；</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-family: " New?? Courier><o:p></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none" align="left"><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " New?? ?Courier mso-bidi-font-family: New?; Courier>的区别：</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-family: " New?? Courier><o:p></o:p></span></div>
<div class=MsoNormal style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none" align="left"><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>字符串直接赋值时，</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt">String</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " 12.0pt? mso-bidi-font-size: Roman?; New Times>类型的变量所引用的值是存储在类的常量池中的。这种情况下，变量的内存空间大小是在编译期就已经确定的。</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt"><o:p></o:p></span></div>
<div><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-bidi-font-family: ; mso-fareast-font-family: 宋体" Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language:>new</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " mso-bidi-font-size: Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: 1.0pt; mso-font-kerning: 12.0pt; mso-bidi-font-family: ?Times>对象的方式是将</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-bidi-font-family: ; mso-fareast-font-family: 宋体" Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language:>”</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-font-kerning: 1.0pt; mso-bidi-font-family: ; mso-fareast-font-family: 宋体" AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: New?; Courier> winwin</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-bidi-font-family: ; mso-fareast-font-family: 宋体" Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language:>”</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " mso-bidi-font-size: Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: 1.0pt; mso-font-kerning: 12.0pt; mso-bidi-font-family: ?Times>存储到</span><span lang=EN-US style="font-size: 10pt; color: #4b4b4b; font-family: georgia; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-bidi-font-family: ; mso-fareast-font-family: 宋体" Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language:>String</span><span style="font-size: 10pt; color: #4b4b4b; font-family: 宋体; mso-ascii-font-family: georgia; mso-hansi-font-family: " mso-bidi-font-size: Roman?; New Times AR-SA? mso-bidi-language: ZH-CN; mso-fareast-language: EN-US; mso-ansi-language: 1.0pt; mso-font-kerning: 12.0pt; mso-bidi-font-family: ?Times>对象的内存空间中，而这个存储动作是在运行期进行的。</span></span></strong></div><br>文章来源:<a href='http://java999.blog.51cto.com/259217/162739'>http://java999.blog.51cto.com/259217/162739</a><img src ="http://www.blogjava.net/yzzh9/aggbug/280912.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yzzh9/" target="_blank">999</a> 2009-06-09 13:41 <a href="http://www.blogjava.net/yzzh9/archive/2009/06/09/280912.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]面试题目字符统计</title><link>http://www.blogjava.net/yzzh9/archive/2009/06/09/280911.html</link><dc:creator>999</dc:creator><author>999</author><pubDate>Tue, 09 Jun 2009 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/yzzh9/archive/2009/06/09/280911.html</guid><wfw:comment>http://www.blogjava.net/yzzh9/comments/280911.html</wfw:comment><comments>http://www.blogjava.net/yzzh9/archive/2009/06/09/280911.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yzzh9/comments/commentRss/280911.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yzzh9/services/trackbacks/280911.html</trackback:ping><description><![CDATA[<font color="#006699">
<div>求第一个无重复字符,如"total"的第一个无重复字符是o,"teeter"的第一个无重复字符是r,效率要优于O(n的平方) <br />public static Character FirstNonRepeated(String)</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>下面是我把别人写的c程序翻译成java程序：</div>
<div>
<div style="border-right: #cccccc 1px solid; padding-right: 4px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 10pt; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; color: #000000; word-break: break-all; line-height: 16px; padding-top: 4px; border-bottom: #cccccc 1px solid; font-family: verdana,宋体; background-color: #eeeeee"><font color="#0000ff">public</font> <font color="#0000ff">class</font> firstNonRepeatedChar {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">private</font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">static</font> <font color="#0000ff">final</font> <font color="#0000ff">int</font> MAX_CHAR = 256;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">public</font> <font color="#0000ff">static</font> <font color="#0000ff">void</font> main(String[] args) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String str = <font color="#800000">"total"</font>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;firstNoRepeatedChar(str);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">public</font> <font color="#0000ff">static</font> <font color="#0000ff">int</font> firstNoRepeatedChar(String str) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">int</font> i = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">int</font> j = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">int</font>[] p = <font color="#0000ff">new</font> <font color="#0000ff">int</font>[MAX_CHAR];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">char</font>[] chars = str.toCharArray();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000">//初始化数组p，p用于保存字符出现的次数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">for</font> (j = 0; j &lt; MAX_CHAR; j++) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p[j] = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000">//统计字符出现的次数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">for</font>(i=0;i&lt;chars.length;i++){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p[chars[i]]++;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000">//寻找第一个统计次数为1的字符&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">for</font> (i = 0; chars[i] != -1; i++) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&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;<font color="#0000ff">if</font> (p[chars[i]] == 1) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&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; System.out.println(chars[i]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&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; <font color="#0000ff">return</font> 1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&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; <br />&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; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">return</font> 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />}&nbsp;&nbsp;&nbsp;&nbsp; <br /></div></div></font><br>文章来源:<a href='http://java999.blog.51cto.com/259217/162744'>http://java999.blog.51cto.com/259217/162744</a><img src ="http://www.blogjava.net/yzzh9/aggbug/280911.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yzzh9/" target="_blank">999</a> 2009-06-09 13:41 <a href="http://www.blogjava.net/yzzh9/archive/2009/06/09/280911.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jsp&amp;Servlet之Cookie</title><link>http://www.blogjava.net/yzzh9/archive/2009/06/09/280910.html</link><dc:creator>999</dc:creator><author>999</author><pubDate>Tue, 09 Jun 2009 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/yzzh9/archive/2009/06/09/280910.html</guid><wfw:comment>http://www.blogjava.net/yzzh9/comments/280910.html</wfw:comment><comments>http://www.blogjava.net/yzzh9/archive/2009/06/09/280910.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yzzh9/comments/commentRss/280910.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yzzh9/services/trackbacks/280910.html</trackback:ping><description><![CDATA[
		<div>
				<font face="Verdana" color="#ff6347">声明：此篇文章为我从网上下载的doc文档里面的一部分内容，具体作者不知。</font>
		</div>
		<div> </div>
		<div> </div>
		<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<font size="3">
						<span lang="EN-US">
								<font face="Verdana">Cookie</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">简介：</span>
						<span lang="EN-US">
								<font face="Verdana">Cookie</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">是服务器保存在客户端上的一组数据。例如，一些登陆网站时会提示是否保存密码，或是选择登陆有效期（浏览器进程、一天、一个月等等），这些都可以使用</span>
						<span lang="EN-US">
								<font face="Verdana">Cookie</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">来实现。</span>
				</font>
		</div>
		<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
						<o:p>
								<font face="Verdana" size="3"> </font>
						</o:p>
				</span>
		</div>
		<div>
				<table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellspacing="0" cellpadding="0" border="1">
						<tbody>
								<tr style="HEIGHT: 22.7pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes">
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 4cm; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 22.7pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" width="151">
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<span lang="EN-US">
																<font face="Verdana">Cookie</font>
														</span>
														<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">类</span>
												</div>
										</td>
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ffffff; WIDTH: 312.7pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 22.7pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" width="417">
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<span lang="EN-US">
																<font face="Verdana">javax.servlet.http.Cookie</font>
														</span>
												</div>
										</td>
								</tr>
								<tr style="HEIGHT: 22.7pt; mso-yfti-irow: 1">
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ffffff; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 4cm; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 22.7pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" width="151">
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">构造方法</span>
												</div>
										</td>
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ffffff; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ffffff; WIDTH: 312.7pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 22.7pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" width="417">
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<span lang="EN-US">
																<font face="Verdana">Cookie(String name,String value)</font>
														</span>
												</div>
										</td>
								</tr>
								<tr style="HEIGHT: 45.75pt; mso-yfti-irow: 2">
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ffffff; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 4cm; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 45.75pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" width="151">
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">服务器<span style="COLOR: fuchsia">向</span>客户端设置</span>
														<span lang="EN-US">
																<font face="Verdana">cookie</font>
														</span>
												</div>
										</td>
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ffffff; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ffffff; WIDTH: 312.7pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 45.75pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" width="417">
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<b style="mso-bidi-font-weight: normal">
																<span lang="EN-US">
																		<font face="Verdana">addCookie(Cookie cookie)<o:p></o:p></font>
																</span>
														</b>
												</div>
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<b style="mso-bidi-font-weight: normal">
																<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">由</span>
																<span lang="EN-US" style="COLOR: fuchsia">
																		<font face="Verdana">response</font>
																</span>
														</b>
														<b style="mso-bidi-font-weight: normal">
																<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">调用，</span>
														</b>
														<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">可反复使用该方法设置多个</span>
														<span lang="EN-US">
																<font face="Verdana">Cookie</font>
														</span>
												</div>
										</td>
								</tr>
								<tr style="HEIGHT: 47.7pt; mso-yfti-irow: 3">
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ffffff; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 4cm; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 47.7pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" width="151">
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">服务器<span style="COLOR: fuchsia">从</span>客户端取回之前保留在客户端上的</span>
														<span lang="EN-US">
																<font face="Verdana">cookie</font>
														</span>
												</div>
										</td>
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ffffff; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ffffff; WIDTH: 312.7pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 47.7pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" width="417">
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<font face="Verdana">
																<b style="mso-bidi-font-weight: normal">
																		<span lang="EN-US">Cookie[]</span>
																</b>
																<span lang="EN-US">
																		<b style="mso-bidi-font-weight: normal">getCookies()<o:p></o:p></b>
																</span>
														</font>
												</div>
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<b style="mso-bidi-font-weight: normal">
																<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">由</span>
																<span lang="EN-US" style="COLOR: fuchsia">
																		<font face="Verdana">request</font>
																</span>
														</b>
														<b style="mso-bidi-font-weight: normal">
																<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">调用</span>
														</b>
												</div>
										</td>
								</tr>
								<tr style="HEIGHT: 47.7pt; mso-yfti-irow: 4; mso-yfti-lastrow: yes">
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ffffff; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 4cm; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 47.7pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" width="151">
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">设置</span>
														<span lang="EN-US">
																<font face="Verdana">cookie</font>
														</span>
														<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">在本地留存的时间</span>
												</div>
										</td>
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ffffff; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ffffff; WIDTH: 312.7pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 47.7pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" width="417">
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<font face="Verdana">
																<b>
																		<span lang="EN-US">setMaxAge</span>
																</b>
																<b style="mso-bidi-font-weight: normal">
																		<span lang="EN-US">(int expiry)<o:p></o:p></span>
																</b>
														</font>
												</div>
												<div class="a" style="MARGIN: 0cm 0cm 0pt">
														<b style="mso-bidi-font-weight: normal">
																<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">由</span>
																<span lang="EN-US">
																		<font face="Verdana">cookie</font>
																</span>
														</b>
														<b style="mso-bidi-font-weight: normal">
																<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">对象调用</span>
																<span lang="EN-US">
																		<o:p>
																		</o:p>
																</span>
														</b>
												</div>
										</td>
								</tr>
						</tbody>
				</table>
		</div>
		<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<o:p>
								<font face="Verdana" size="3"> </font>
						</o:p>
				</span>
		</div>
		<div class="2" style="MARGIN: 2pt 0cm 2pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l1 level1 lfo2">
				<span lang="EN-US" style="FONT-WEIGHT: normal; FONT-FAMILY: wingdings; mso-bidi-font-family: wingdings; mso-fareast-font-family: wingdings; mso-bidi-font-weight: bold">
						<span style="mso-list: ignore">
								<font size="3">l</font>
						</span>
				</span>
				<strong>
						<font size="3">
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">示例：设置</span>
								<span lang="EN-US">
										<font face="Verdana">Cookie</font>
								</span>
						</font>
				</strong>
		</div>
		<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<font size="3">
						<span lang="EN-US">
								<font face="Verdana">cookie01.jsp </font>
						</span>
						<span lang="EN-US" style="FONT-FAMILY: wingdings; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana; mso-char-type: symbol; mso-symbol-font-family: wingdings">
								<span style="mso-char-type: symbol; mso-symbol-font-family: wingdings">à</span>
						</span>
						<span lang="EN-US">
								<font face="Verdana">
								</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">服务器响应客户的请求时，设置</span>
						<span lang="EN-US">
								<font face="Verdana">cookie</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">到客户端：</span>
				</font>
		</div>
		<div class="a" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; tab-stops: list 42.0pt; mso-list: l0 level1 lfo1">
				<span lang="EN-US" style="FONT-FAMILY: wingdings; mso-bidi-font-family: wingdings; mso-fareast-font-family: wingdings">
						<span style="mso-list: ignore">
								<font size="3">²</font>
						</span>
				</span>
				<font size="3">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">先准备好</span>
						<span lang="EN-US">
								<font face="Verdana">cookie</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">对象</span>
				</font>
		</div>
		<div>
				<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">然后利用</span>
				<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:=""> response.addCookie(Cookie cookie)</span>
				<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">进行设置</span>
		</div>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">
				<div>
						<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee">&lt;%    <br />          <font color="#008000">//构造Cookie对象，构造方法：Cookie(String name,String value) </font><br />          Cookie c1= <font color="#0000ff">new</font> Cookie(<font color="#800000">"name"</font>,<font color="#800000">"Jerry"</font>); <br />          Cookie c2= <font color="#0000ff">new</font> Cookie(<font color="#800000">"password"</font>,<font color="#800000">"1234"</font>); <br />          Cookie c3= <font color="#0000ff">new</font> Cookie(<font color="#800000">"access_time"</font>,<font color="#0000ff">new</font> Date().toString()); <br />            <br />          <font color="#008000">//将Cookie设置给客户端 </font><br />          <font color="#008000">//服务器向客户端传递数据，使用response对象 </font><br />          <font color="#008000">//方法：reponse.addCookie(Cookie cookie) </font><br />            <br />          response.addCookie(c1); <br />          response.addCookie(c2); <br />          response.addCookie(c3); <br />%&gt; <br /></div>
				</div>
				<div> </div>
				<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">【注】浏览器窗口中看不到</span>
						<span lang="EN-US">
								<font face="Verdana">Cookie</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">的信息</span>
				</div>
				<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
						<span lang="EN-US">
								<o:p>
										<font face="Verdana"> </font>
								</o:p>
						</span>
				</div>
				<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
						<span lang="EN-US">
								<font face="Verdana">Cookie02.jsp </font>
						</span>
						<span lang="EN-US" style="FONT-FAMILY: wingdings; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana; mso-char-type: symbol; mso-symbol-font-family: wingdings">
								<span style="mso-char-type: symbol; mso-symbol-font-family: wingdings">à</span>
						</span>
						<span lang="EN-US">
								<font face="Verdana">
								</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">如果需要，服务器可以从客户端取回</span>
						<span lang="EN-US">
								<font face="Verdana">cookie</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">，这是<span style="COLOR: fuchsia">从客户端传数据到服务器</span>，故要使用</span>
						<span lang="EN-US">
								<font face="Verdana">request</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">的方法：</span>
						<font face="Verdana">
								<b style="mso-bidi-font-weight: normal">
										<span lang="EN-US">Cookie[]</span>
								</b>
								<span lang="EN-US">
										<b style="mso-bidi-font-weight: normal">request.getCookies()</b>
								</span>
						</font>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">。</span>
				</div>
				<div class="a" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; tab-stops: list 42.0pt; mso-list: l0 level1 lfo1">
						<span lang="EN-US" style="FONT-FAMILY: wingdings; mso-bidi-font-family: wingdings; mso-fareast-font-family: wingdings">
								<span style="mso-list: ignore">²</span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">利用</span>
						<span lang="EN-US">
								<font face="Verdana">request.getCookies()</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">取得</span>
						<span lang="EN-US">
								<font face="Verdana">cookie</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">数组</span>
				</div>
				<div>
						<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">遍历数组，取得其中每一个</span>
						<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:="">cookie</span>
				</div>
				<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:="">
						<div>
								<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee">&lt;% <br />          <font color="#008000">//Cookie[] request.getCookies()方法 </font><br />          Cookie[] cs = request.getCookies(); <br />            <br />          <font color="#0000ff">for</font>(<font color="#0000ff">int</font> i=0;i&lt;cs.length;i++){             <br />            Cookie tmp = cs[i];     <br />            <font color="#008000">//每一个Cookie由 name--value构成 </font><br />            <font color="#008000">//可以使用 String getName() 和 String getValue() 获得各成分的值 </font><br />                     <br />        %&gt;    <br />            <br />          &lt;h1&gt; &lt;%= tmp.getName() %&gt; &lt;%=tmp.getValue() %&gt; &lt;/h1&gt; <br />        &lt;%    <br />          }        <br />            <br />          <font color="#008000">//JSESSIONID ACCE027387AADBD63525E4446F1DFD83是服务器自动设置的 </font><br />          <font color="#008000">//代表这个客户端在服务器上的一个唯一编号 </font><br />%&gt; <br /></div>
						</div>
						<div> </div>
						<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">【注】：每一个</span>
								<span lang="EN-US">
										<font face="Verdana">cookie</font>
								</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">都是由</span>
								<span lang="EN-US">
										<font face="Verdana"> name – value</font>
								</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">构成（由构造方法可知），</span>
								<span lang="EN-US">
										<font face="Verdana">Cookie</font>
								</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">类提供了如下</span>
								<span lang="EN-US">
										<font face="Verdana">2</font>
								</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">个方法获取</span>
								<span lang="EN-US">
										<font face="Verdana">cookie</font>
								</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">的</span>
								<span lang="EN-US">
										<font face="Verdana">name</font>
								</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">和</span>
								<span lang="EN-US">
										<font face="Verdana">value</font>
								</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">的值：</span>
						</div>
						<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
								<b style="mso-bidi-font-weight: normal">
										<span lang="EN-US">
												<font face="Verdana">String getName()<o:p></o:p></font>
										</span>
								</b>
						</div>
						<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
								<b style="mso-bidi-font-weight: normal">
										<span lang="EN-US">
												<font face="Verdana">String getValue()</font>
										</span>
								</b>
						</div>
						<div class="a" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
								<span lang="EN-US">
										<o:p>
												<font face="Verdana"> </font>
										</o:p>
								</span>
						</div>
						<div class="2" style="MARGIN: 2pt 0cm 2pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l1 level1 lfo1">
								<span lang="EN-US" style="FONT-WEIGHT: normal; FONT-FAMILY: wingdings; mso-bidi-font-family: wingdings; mso-fareast-font-family: wingdings; mso-bidi-font-weight: bold">
										<span style="mso-list: ignore">l</span>
								</span>
								<strong>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">设置</span>
										<span lang="EN-US">
												<font face="Verdana">Cookie</font>
										</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">的保存时间</span>
								</strong>
						</div>
						<div class="a" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; tab-stops: list 42.0pt; mso-list: l0 level1 lfo2">
								<a name="OLE_LINK1">
										<font face="Verdana">
												<span lang="EN-US" style="FONT-FAMILY: wingdings; mso-bidi-font-family: wingdings; mso-fareast-font-family: wingdings">
														<span style="mso-list: ignore">²</span>
												</span>
												<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">默认情况</span>
										</font>
								</a>
								<font face="Verdana">
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">下：</span>
										<span lang="EN-US">cookie</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">是仅在浏览器进程中有效。</span>
								</font>
						</div>
						<div class="a" style="MARGIN: 0cm 0cm 0pt 21pt">
								<font face="Verdana">
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">（在一个窗口中先运行</span>
										<span lang="EN-US"> cookie01.jsp</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">实现设置</span>
										<span lang="EN-US">cookie</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">，然后仍然在这个窗口中运行</span>
										<span lang="EN-US"> cookie02.jsp </span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">取回</span>
										<span lang="EN-US">cookie </span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">并显示</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">是可以实现。但，如果在另外的浏览器窗口中直接运行</span>
										<span lang="EN-US"> cookie02.jsp </span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">，则无法再取回之前设置的</span>
										<span lang="EN-US">cookie</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">了）</span>
								</font>
						</div>
						<div class="a" style="MARGIN: 0cm 0cm 0pt 21pt">
								<span lang="EN-US">
										<o:p>
												<font face="Verdana"> </font>
										</o:p>
								</span>
						</div>
						<div class="a" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; tab-stops: list 42.0pt; mso-list: l0 level1 lfo2">
								<font face="Verdana">
										<span lang="EN-US" style="FONT-FAMILY: wingdings; mso-bidi-font-family: wingdings; mso-fareast-font-family: wingdings">
												<span style="mso-list: ignore">²</span>
										</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">如果希望</span>
										<span lang="EN-US">cookie</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">能在本地留存一段时间，使得在一段时间之内都可以取回</span>
										<span lang="EN-US">cookie</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">，则可以利用</span>
										<span lang="EN-US">Cookie</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">类的</span>
										<b style="mso-bidi-font-weight: normal">
												<span lang="EN-US">setMaxAge(int expiry)</span>
										</b>
										<span lang="EN-US">
										</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">方法，</span>
										<span lang="EN-US">expiry</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">表多少秒后</span>
										<span lang="EN-US">cookie</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">过期。</span>
								</font>
						</div>
						<div class="a" style="MARGIN: 0cm 0cm 0pt 21pt">
								<span lang="EN-US">
										<o:p>
												<font face="Verdana"> </font>
										</o:p>
								</span>
						</div>
						<div>
								<font face="Verdana">
										<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">修改</span>
										<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:="">cookie01.jsp </span>
										<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">为</span>
										<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:=""> cookie03.jsp </span>
										<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">，增加</span>
										<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:="">cookie</span>
										<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">留存时间的设置，仍然使用</span>
										<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:="">cookie02.jsp</span>
										<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">取回</span>
										<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:="">cookie</span>
								</font>
						</div>
						<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 1.0pt;="" mso-font-kerning:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:="">
								<div>
										<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee">&lt;h1&gt;利用Cookie类的setMaxAge(<font color="#0000ff">int</font> expiry)可是设置cookie在本地计算机上留存一段时间，单位是秒&lt;/h1&gt; <br /><br />    &lt;% <br />              <font color="#008000">//构造Cookie对象，构造方法：Cookie(String name,String value) </font><br />              Cookie c1= <font color="#0000ff">new</font> Cookie(<font color="#800000">"name"</font>,<font color="#800000">"Jerry"</font>); <br />              Cookie c2=<font color="#0000ff">new</font> Cookie(<font color="#800000">"password"</font>,<font color="#800000">"1234"</font>); <br />              Cookie c3=<font color="#0000ff">new</font> Cookie(<font color="#800000">"access_time"</font>,<font color="#0000ff">new</font> Date().toString()); <br />                <br />              <font color="#008000">//设置留存时间30秒 </font><br />              c1.setMaxAge(30); <br />              c2.setMaxAge(30); <br />              c3.setMaxAge(30); <br />                <br />              <font color="#008000">//将Cookie设置给客户端 </font><br />              <font color="#008000">//服务器向客户端传递数据，使用response对象 </font><br />              <font color="#008000">//方法：reponse.addCookie(Cookie cookie) </font><br />                <br />              response.addCookie(c1); <br />              response.addCookie(c2); <br />              response.addCookie(c3); <br />    %&gt; <br /></div>
								</div>
								<div> </div>
								<div class="a0" style="MARGIN: 0cm 0cm 0pt 21pt">
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">则运行</span>
										<span lang="EN-US">
												<font face="Verdana"> cookie03.jsp</font>
										</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">完成设置</span>
										<span lang="EN-US">
												<font face="Verdana">cookie</font>
										</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">后，即使另开一个浏览器窗口，直接运行</span>
										<span lang="EN-US">
												<font face="Verdana"> cookie02.jsp </font>
										</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">仍然可以取回</span>
										<span lang="EN-US">
												<font face="Verdana">cookie</font>
										</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">，</span>
										<font face="Verdana">
										</font>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">但时限到了之后</span>
										<span lang="EN-US">
												<font face="Verdana">cookie</font>
										</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">还是会失效。</span>
								</div>
								<div class="a0" style="MARGIN: 0cm 0cm 0pt 21pt">
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">但是，服务器自动设置的</span>
										<span lang="EN-US">
												<font face="Verdana">JSESSIONID</font>
										</span>
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana">还在。</span>
								</div>
								<div class="a" style="MARGIN: 0cm 0cm 0pt">
										<span lang="EN-US" style="mso-fareast-font-family: 宋体">
												<o:p> </o:p>
										</span>
								</div>
								<div class="a0" style="MARGIN: 0cm 0cm 0pt">
										<span lang="EN-US" style="mso-font-kerning: 0pt">
												<o:p>
														<font face="Verdana"> </font>
												</o:p>
										</span>
								</div>
								<div>
										<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">我的备注：一个</span>
										<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:="">servlet/jsp</span>
										<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">设置的路径能够被同一路径或子路径下的</span>
										<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 12.0pt;="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" 宋体;="" mso-fareast-font-family:="">servlet/jsp</span>
										<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 12.0pt;="" mso-bidi-font-family:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" ?times="" mso-hansi-font-family:="">访问到，其它路径不能访问到。</span>
								</div>
						</span>
				</span>
		</span>
		<br />
<img src ="http://www.blogjava.net/yzzh9/aggbug/280910.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yzzh9/" target="_blank">999</a> 2009-06-09 13:41 <a href="http://www.blogjava.net/yzzh9/archive/2009/06/09/280910.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jsp&amp;Servlet之Session对象</title><link>http://www.blogjava.net/yzzh9/archive/2009/06/09/280909.html</link><dc:creator>999</dc:creator><author>999</author><pubDate>Tue, 09 Jun 2009 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/yzzh9/archive/2009/06/09/280909.html</guid><wfw:comment>http://www.blogjava.net/yzzh9/comments/280909.html</wfw:comment><comments>http://www.blogjava.net/yzzh9/archive/2009/06/09/280909.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yzzh9/comments/commentRss/280909.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yzzh9/services/trackbacks/280909.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 声明：此篇文章为从网上下载的doc文档中的摘取，彩色部分为本人的笔记。																																																		 																				u																																						session						...&nbsp;&nbsp;<a href='http://www.blogjava.net/yzzh9/archive/2009/06/09/280909.html'>阅读全文</a><img src ="http://www.blogjava.net/yzzh9/aggbug/280909.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yzzh9/" target="_blank">999</a> 2009-06-09 13:41 <a href="http://www.blogjava.net/yzzh9/archive/2009/06/09/280909.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>forward、sendRedirect及Jsp和Servlet之间的跳转</title><link>http://www.blogjava.net/yzzh9/archive/2009/06/09/280908.html</link><dc:creator>999</dc:creator><author>999</author><pubDate>Tue, 09 Jun 2009 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/yzzh9/archive/2009/06/09/280908.html</guid><wfw:comment>http://www.blogjava.net/yzzh9/comments/280908.html</wfw:comment><comments>http://www.blogjava.net/yzzh9/archive/2009/06/09/280908.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yzzh9/comments/commentRss/280908.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yzzh9/services/trackbacks/280908.html</trackback:ping><description><![CDATA[
		<div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">&lt;jsp:forward&gt;</span>
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">使用同一个</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">request</span>
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">，是在服务器端跳转，浏览器显示的是第一个页面的名字，因为客户端（浏览器）不知道它在服务器端跳转了。</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">
						<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
						<o:p>
						</o:p>
				</span>
		</div>
		<div>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" courier="" new?;="" ?times="" 宋体;="" mso-fareast-font-family:="">Response.sendRedirect</span>
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:="">是两个不同的</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" courier="" new?;="" ?times="" 宋体;="" mso-fareast-font-family:="">request</span>
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:="">，是在客户端跳转，浏览器显示的是跳转后的页面的名字。因为它是从客户端跳转到第二个页面的。</span>
		</div>
		<div>
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:="">
				</span> </div>
		<div>
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:="">
						<img onclick="window.open(this.src)" alt="" src="http://blog.51cto.com/attachment/200906/200906091244525332718.jpg" border="0" />
				</span>
		</div>
		<div>
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:="">
				</span> </div>
		<div>
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:="">
						<img onclick="window.open(this.src)" alt="" src="http://blog.51cto.com/attachment/200906/200906091244525370718.jpg" border="0" />
				</span>
		</div>
		<div>
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:="">
				</span> </div>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:="">
				<div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt">
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">使用</span>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">forward</span>
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">时，由于只是发送一次</span>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">request</span>
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">请求，</span>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">request</span>
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">设置的属性（</span>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">setAttribute</span>
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">）依然能保留在下一个页面。</span>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">
								<o:p>
								</o:p>
						</span>
				</div>
				<div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt">
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">使用</span>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">sendRedirect</span>
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">时，由于发送两次</span>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">request</span>
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">请求，所以在下一个不能获取</span>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">request</span>
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">属性。但可以通过重写</span>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">URL</span>
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">的方式将内容传递过去。</span>
						<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">
								<o:p>
								</o:p>
						</span>
				</div>
				<div>
						<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:="">下面举例说明：</span>
				</div>
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:="">
						<div>
								<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee">
										<img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />tian.jsp    <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />&lt;%request.setAttribute(<font color="#800000">"river"</font>,<font color="#800000">"redwater"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />    request.setAttribute(<font color="#800000">"country"</font>,<font color="#800000">"daguaiwan"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />%&gt; <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />&lt;jsp:forward page=<font color="#800000">"fengshan.jsp"</font> /&gt; <br /></div>
						</div>
						<div> </div>
						<div>
						</div>
				</span> <div><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee"><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />donglan.jsp    <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />&lt;%request.setAttribute(<font color="#800000">"river"</font>,<font color="#800000">"redwater"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />    request.setAttribute(<font color="#800000">"country"</font>,<font color="#800000">"daguaiwan"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />%&gt; <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />&lt;a href=<font color="#800000">"fengshan.jsp"</font>&gt;fengshan&lt;/a&gt; <br /></div></div><div><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:=""></span> </div><div><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:=""></span> </div><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:=""><div><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee"><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />bama.jsp    <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />&lt;%request.setAttribute(<font color="#800000">"river"</font>,<font color="#800000">"redwater"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />    request.setAttribute(<font color="#800000">"country"</font>,<font color="#800000">"daguaiwan"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />    response.sendRedirect(<font color="#800000">"fengshan.jsp"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />%&gt; <br /></div></div><div> </div><div> </div><div><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee"><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />fengshan.jsp <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />&lt;%=request.getAttribute(<font color="#800000">"river"</font>)%&gt;&lt;br/&gt; <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />&lt;%=request.getAttribute(<font color="#800000">"country"</font>)%&gt; <br /></div></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span lang="EN-US"><a href="http://localhost:8080/ForwardRedirect/tiane.jsp"><font face="Times New Roman" size="3">http://localhost:8080/ForwardRedirect/tiane.jsp</font></a><font face="Times New Roman" size="3"></font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: " times="" new="" roman?;="" ?times="" roman??="" mso-hansi-font-family:=""><font size="3">跳转后结果为：</font></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><font size="3"><font face="Times New Roman"><span lang="EN-US" style="BACKGROUND: black; COLOR: white; mso-highlight: black">redwater<br />daguaiwan</span><span lang="EN-US" style="COLOR: white"><o:p></o:p></span></font></font></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span lang="EN-US" style="COLOR: white"><o:p><font face="Times New Roman" size="3"> </font></o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span lang="EN-US"><a href="http://localhost:8080/ForwardRedirect/donglan.jsp"><font face="Times New Roman" size="3">http://localhost:8080/ForwardRedirect/donglan.jsp</font></a><font face="Times New Roman" size="3"></font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: " times="" new="" roman?;="" ?times="" roman??="" mso-hansi-font-family:=""><font size="3">跳转后结果为：</font></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><font size="3"><font face="Times New Roman"><span lang="EN-US" style="BACKGROUND: black; COLOR: white; mso-highlight: black">null<br />null</span><span lang="EN-US" style="COLOR: white"><o:p></o:p></span></font></font></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span lang="EN-US"><o:p><font face="Times New Roman" size="3"> </font></o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span lang="EN-US"><a href="http://localhost:8080/ForwardRedirect/bama.jsp"><font face="Times New Roman" size="3">http://localhost:8080/ForwardRedirect/bama.jsp</font></a><font face="Times New Roman" size="3"></font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: " times="" new="" roman?;="" ?times="" roman??="" mso-hansi-font-family:=""><font size="3">跳转后结果为：</font></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><font size="3"><font face="Times New Roman"><span lang="EN-US" style="BACKGROUND: black; COLOR: white; mso-highlight: black">null<br />null</span><span lang="EN-US" style="COLOR: white"><o:p></o:p></span></font></font></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span lang="EN-US"><o:p><font face="Times New Roman" size="3"> </font></o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">结果分析：</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?=""><o:p></o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">tiane.jsp</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">是通过</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">forward</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">跳转到</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">fengshan.jsp</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">的，这两个页面享用的是同一个</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">request</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">，故</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">fengshan.jsp</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">可以接收到</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">tiane.jsp</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">通过</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?=""> request</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">设置的属性。</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?=""><o:p></o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">而</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">donglan.jsp</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">是通过</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">href</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">发送了另外的</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">request</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">请求，</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">bama.jsp</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">是通过</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">sendRedirect</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">跳转，用的也是另外的</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">request</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">请求，故</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">fengshan.jsp</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">不可以接收到这两个页面通过</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?=""> request</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">设置的属性。</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?=""><o:p></o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?=""><o:p> </o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">Jsp</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">和</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">Servlet</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">之间的跳转：</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?=""><o:p></o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">从</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">Jsp</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">跳转</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">Servlet</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">可以使用</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">&lt;jsp:forward page=”URL” /&gt;</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">或者</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">response.sendRedirect(URL)</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">都可以，它们之间的区别上面已经说明了。</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?=""><o:p></o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?=""><o:p> </o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1; tab-stops: 105.75pt"><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">从</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">Servlet</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">跳转</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?="">Jsp</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ; mso-font-kerning: 0pt" new="" courier="" new?;="" ?times="" roman??="" mso-hansi-font-family:="">：</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-bidi-font-size:="" mso-font-kerning:="" 12.0pt;="" mso-bidi-font-family:="" new="" roman?;="" courier="" new?;="" ?times="" 0pt?=""><o:p></o:p></span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-outline-level: 1; tab-stops: list 21.0pt left 95.5pt; mso-list: l0 level1 lfo1"><span lang="EN-US" style="FONT-FAMILY: wingdings; mso-bidi-font-family: wingdings; mso-fareast-font-family: wingdings"><span style="mso-list: ignore"><font size="3">²</font><span style="FONT-WEIGHT: normal; FONT-SIZE: 7pt; LINE-HEIGHT: normal; FONT-STYLE: normal; FONT-VARIANT: normal" times="" new="" roman??="">        </span></span></span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-font-kerning:="" courier="" new?;="" 0pt?="">getRequestDispatcher</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-family: " mso-font-kerning:="" courier="" new?;="" ?courier="" new??="" mso-hansi-font-family:="" mso-ascii-font-family:="" 0pt;="">的</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-font-kerning:="" courier="" new?;="" 0pt?="">forward(request, response)</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-family: " mso-font-kerning:="" courier="" new?;="" ?courier="" new??="" mso-hansi-font-family:="" mso-ascii-font-family:="" 0pt;="">方法，这里也只是发送了一次请求，可以在下一个页面接受</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-font-kerning:="" courier="" new?;="" 0pt?="">request</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-family: " mso-font-kerning:="" courier="" new?;="" ?courier="" new??="" mso-hansi-font-family:="" mso-ascii-font-family:="" 0pt;="">设置的属性。</span></div><div class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-outline-level: 1; tab-stops: list 21.0pt left 95.5pt; mso-list: l0 level1 lfo1"><span lang="EN-US" style="FONT-FAMILY: wingdings; mso-bidi-font-family: wingdings; mso-fareast-font-family: wingdings"><span style="mso-list: ignore"><font size="3">²</font><span style="FONT-WEIGHT: normal; FONT-SIZE: 7pt; LINE-HEIGHT: normal; FONT-STYLE: normal; FONT-VARIANT: normal" times="" new="" roman??="">        </span></span></span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-font-kerning:="" courier="" new?;="" 0pt?="">response.sendRedirect(URL),</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-family: " mso-font-kerning:="" courier="" new?;="" ?courier="" new??="" mso-hansi-font-family:="" mso-ascii-font-family:="" 0pt;="">这里发送了两次请求，不可以在下一个页面接受</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: " mso-font-kerning:="" courier="" new?;="" 0pt?="">request</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-family: " mso-font-kerning:="" courier="" new?;="" ?courier="" new??="" mso-hansi-font-family:="" mso-ascii-font-family:="" 0pt;="">设置的属性。</span></div><div><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" en-us;="" zh-cn;="" ar-sa?="" courier="" new?;="" ?courier="" mso-hansi-font-family:="" mso-ascii-font-family:="">例子如下：</span></div><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" en-us;="" zh-cn;="" ar-sa?="" courier="" new?;="" ?courier="" mso-hansi-font-family:="" mso-ascii-font-family:=""><div><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee"><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />servlettiane.jsp    <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />&lt;%request.setAttribute(<font color="#800000">"river"</font>,<font color="#800000">"redwater"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />    request.setAttribute(<font color="#800000">"country"</font>,<font color="#800000">"daguaiwan"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />%&gt; <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />&lt;jsp:forward page=<font color="#800000">"/tiane"</font> /&gt; <br /></div></div><div> </div><div><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee"><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />servletbama.jsp    <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />&lt;%request.setAttribute(<font color="#800000">"river"</font>,<font color="#800000">"redwater"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />    request.setAttribute(<font color="#800000">"country"</font>,<font color="#800000">"daguaiwan"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />    response.sendRedirect(<font color="#800000">"/ForwardRedirect/tiane"</font>); <br /><img onclick="window.open(this.src)" src="http://blog.51cto.com/images/editer/InBlock.gif" align="top" />%&gt; <br /></div></div><div> </div><div><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee">Tiane.java <br /><font color="#0000ff">public</font><font color="#0000ff">class</font> Tiane <font color="#0000ff">extends</font> HttpServlet { <br /><br />  <font color="#0000ff">public</font><font color="#0000ff">void</font> doGet(HttpServletRequest request, HttpServletResponse response) <br />      <font color="#0000ff">throws</font> ServletException, IOException { <br /><font color="#008000">//    response.sendRedirect("/ForwardRedirect/fengshan.jsp"); </font><br />    <font color="#0000ff">this</font>.getServletConfig().getServletContext() <br />            .getRequestDispatcher(<font color="#800000">"/fengshan.jsp"</font>).forward(request, response); <br />  } <br /><br />  <font color="#0000ff">public</font><font color="#0000ff">void</font> doPost(HttpServletRequest request, HttpServletResponse response) <br />      <font color="#0000ff">throws</font> ServletException, IOException { <br />    doGet(request, response); <br />  }    <br />} <br /></div></div><div> </div><div><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 10pt; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; COLOR: #000000; WORD-BREAK: break-all; LINE-HEIGHT: 16px; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: verdana,宋体; BACKGROUND-COLOR: #eeeeee">再在web.xml中配置servlet： <br />  <font color="#0000ff">&lt;</font><font color="#800000">servlet</font><font color="#0000ff">&gt;</font><br />  <font color="#0000ff">&lt;</font><font color="#800000">servlet-name</font><font color="#0000ff">&gt;</font>tiane<font color="#0000ff">&lt;/</font><font color="#800000">servlet-name</font><font color="#0000ff">&gt;</font><br />  <font color="#0000ff">&lt;</font><font color="#800000">servlet-class</font><font color="#0000ff">&gt;</font>com.dvnchina.test.Tiane<font color="#0000ff">&lt;/</font><font color="#800000">servlet-class</font><font color="#0000ff">&gt;</font><br />  <font color="#0000ff">&lt;/</font><font color="#800000">servlet</font><font color="#0000ff">&gt;</font><br />  <font color="#0000ff">&lt;</font><font color="#800000">servlet-mapping</font><font color="#0000ff">&gt;</font><br />  <font color="#0000ff">&lt;</font><font color="#800000">servlet-name</font><font color="#0000ff">&gt;</font>tiane<font color="#0000ff">&lt;/</font><font color="#800000">servlet-name</font><font color="#0000ff">&gt;</font><br />  <font color="#0000ff">&lt;</font><font color="#800000">url-pattern</font><font color="#0000ff">&gt;</font>/tiane<font color="#0000ff">&lt;/</font><font color="#800000">url-pattern</font><font color="#0000ff">&gt;</font><br /><font color="#0000ff">&lt;/</font><font color="#800000">servlet-mapping</font><font color="#0000ff">&gt;</font><br /></div></div><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" en-us;="" zh-cn;="" ar-sa?="" courier="" new?;="" ?courier="" mso-hansi-font-family:="" mso-ascii-font-family:="">具体的结果我就不分析了，和第一个例子差不多的。代码见附件。</span><div></div></span> <div></div></span></span> <div><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: " mso-bidi-language:="" mso-fareast-language:="" mso-ansi-language:="" times="" new="" roman?;="" en-us;="" zh-cn;="" ar-sa?="" new?;="" ?courier="" ?times="" mso-hansi-font-family:="" mso-ascii-font-family:=""></span> </div><br /><img src ="http://www.blogjava.net/yzzh9/aggbug/280908.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yzzh9/" target="_blank">999</a> 2009-06-09 13:41 <a href="http://www.blogjava.net/yzzh9/archive/2009/06/09/280908.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]Powerdesigner的使用</title><link>http://www.blogjava.net/yzzh9/archive/2009/06/07/280492.html</link><dc:creator>999</dc:creator><author>999</author><pubDate>Sun, 07 Jun 2009 12:39:00 GMT</pubDate><guid>http://www.blogjava.net/yzzh9/archive/2009/06/07/280492.html</guid><wfw:comment>http://www.blogjava.net/yzzh9/comments/280492.html</wfw:comment><comments>http://www.blogjava.net/yzzh9/archive/2009/06/07/280492.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yzzh9/comments/commentRss/280492.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yzzh9/services/trackbacks/280492.html</trackback:ping><description><![CDATA[<div class=MsoNormal style="margin: 0cm 0cm 0pt; word-break: break-all; line-height: 160%"><b><span style="font-size: 11pt; color: #4b4b4b; line-height: 160%; font-family: 宋体; mso-ascii-font-family: verdana; mso-hansi-font-family: verdana"></span></b><b><span lang=EN-US style="font-size: 11pt; color: #4b4b4b; line-height: 160%; font-family: verdana"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>sql脚本如何导入Powerdesigner ？</o:p></span></b></div>
<div><font size="3"><font face=宋体>答：<span lang=EN-US>1.</span>打开<span lang=EN-US>pd,</span>新建<span lang=EN-US>PhysicalData Model</span></font></font></div>
<div><font size="3"><font face=宋体>选择<span lang=EN-US>New Model</span>，<span lang=EN-US>DBMS</span>为你使用的数据库，例如<span lang=EN-US>:sql server 2000</span></font></font></div>
<div><font size="3"><font face=宋体><span lang=EN-US>First diagram</span>选择<span lang=EN-US>Physical Diagram</span></font></font></div>
<div><font size="3"><font face=宋体><span lang=EN-US>2.</span>选择<span lang=EN-US>DataBase</span>下的<span lang=EN-US>Reverse Engineer Database</span></font></font></div>
<div><font size="3"><font face=宋体><span lang=EN-US>&nbsp;------Using Script files---Add files</span>，选中脚本所在地址<span lang=EN-US>,</span>确定即可。</font></font></div><br>文章来源:<a href='http://java999.blog.51cto.com/259217/128798'>http://java999.blog.51cto.com/259217/128798</a><img src ="http://www.blogjava.net/yzzh9/aggbug/280492.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yzzh9/" target="_blank">999</a> 2009-06-07 20:39 <a href="http://www.blogjava.net/yzzh9/archive/2009/06/07/280492.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>