⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 代码清单2-22.htm

📁 《深入浅出Ajax》 源代码
💻 HTM
📖 第 1 页 / 共 2 页
字号:
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#<span class=GramE>003<span style='mso-spacerun:yes'>&nbsp;
</span>String</span> <span class=SpellE>responseType</span> = <span
class=SpellE>request.getParameter</span>(&quot;<span class=SpellE>responseType</span>&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#<span class=GramE>004<span style='mso-spacerun:yes'>&nbsp;
</span><span class=SpellE>StringBuffer</span></span> <span class=SpellE>sb</span>
= new <span class=SpellE>StringBuffer</span>();<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#<span class=GramE>005<span style='mso-spacerun:yes'>&nbsp;
</span>if</span>(<span class=SpellE>responseType</span>!=<span class=SpellE>null&amp;&amp;!responseType.equals</span>(&quot;&quot;)){<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#<span class=GramE>006<span style='mso-spacerun:yes'>&nbsp;
</span>if</span>(<span class=SpellE>responseType.equals</span>(&quot;<span
class=SpellE>simpleText</span>&quot;)){<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#007<span style='mso-spacerun:yes'>&nbsp; </span>//</span><span
style='font-size:9.0pt;font-family:仿宋_GB2312;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"MS Reference Sans Serif";mso-bidi-font-family:"Times New Roman"'>返回简单文本</span><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'><o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#008<span style='mso-spacerun:yes'>&nbsp; </span><span
class=SpellE>System.out.println</span>(&quot;</span><span style='font-size:
9.0pt;font-family:仿宋_GB2312;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"MS Reference Sans Serif";mso-bidi-font-family:"Times New Roman"'>返回简单文本</span><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#<span class=GramE>009<span style='mso-spacerun:yes'>&nbsp;
</span><span class=SpellE>response.addHeader</span></span>(&quot;Content-<span
class=SpellE>Type&quot;,&quot;text</span>/html&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#010<span style='mso-spacerun:yes'>&nbsp; </span><span
class=SpellE>sb.append</span>(&quot;</span><span style='font-size:9.0pt;
font-family:仿宋_GB2312;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"MS Reference Sans Serif";mso-bidi-font-family:"Times New Roman"'>简单文本</span><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#<span class=GramE>011<span style='mso-spacerun:yes'>&nbsp;
</span>}else</span> if(<span class=SpellE>responseType.equals</span>(&quot;html&quot;)){<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#012<span style='mso-spacerun:yes'>&nbsp; </span>//</span><span
style='font-size:9.0pt;font-family:仿宋_GB2312;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"MS Reference Sans Serif";mso-bidi-font-family:"Times New Roman"'>返回</span><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>HTML<span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp; </span><o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#013<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE>System.out.println</span>(&quot;</span><span style='font-size:
9.0pt;font-family:仿宋_GB2312;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"MS Reference Sans Serif";mso-bidi-font-family:"Times New Roman"'>返回</span><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>HTML&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#014<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE><span class=GramE>response.addHeader</span></span><span
class=GramE>(</span>&quot;Content-<span class=SpellE>Type&quot;,&quot;text</span>/html&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#015<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE>sb.append</span>(&quot;&lt;h1&gt;HTML</span><span
style='font-size:9.0pt;font-family:仿宋_GB2312;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"MS Reference Sans Serif";mso-bidi-font-family:"Times New Roman"'>代码</span><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>&lt;h1&gt;&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#016<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=GramE>}else</span> if(<span class=SpellE>responseType.equals</span>(&quot;xml&quot;)){<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#017<span style='mso-spacerun:yes'>&nbsp; </span>//</span><span
style='font-size:9.0pt;font-family:仿宋_GB2312;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"MS Reference Sans Serif";mso-bidi-font-family:"Times New Roman"'>返回</span><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>XML<span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#018<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE>System.out.println</span>(&quot;</span><span style='font-size:
9.0pt;font-family:仿宋_GB2312;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"MS Reference Sans Serif";mso-bidi-font-family:"Times New Roman"'>返回</span><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>XML&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#019<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE><span class=GramE>response.addHeader</span></span><span
class=GramE>(</span>&quot;Content-<span class=SpellE>Type&quot;,&quot;text</span>/xml&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#020<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<span
class=SpellE><span class=GramE>sb.append</span></span><span class=GramE>(</span>&quot;&lt;?xml
version=\&quot;1.0\&quot; encoding=\&quot;GBK\&quot;?&gt;&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#021<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE><span class=GramE>sb.append</span></span><span class=GramE>(</span>&quot;&lt;<span
class=SpellE>xmldata</span>&gt;&lt;content&gt;&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#022<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE><span class=GramE>sb.append</span></span><span class=GramE>(</span>&quot;XML&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#023<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE><span class=GramE>sb.append</span></span><span class=GramE>(</span>&quot;&lt;/content&gt;&lt;/<span
class=SpellE>xmldata</span>&gt;&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#024<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#025<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE><span class=GramE>out.write</span></span><span class=GramE>(</span><span
class=SpellE>sb.toString</span>());<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#<span class=GramE>026<span style='mso-spacerun:yes'>&nbsp;
</span>}else</span>{<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#027<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE><span class=GramE>System.out.println</span></span><span
class=GramE>(</span>&quot;bad request&quot;);<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#028<span style='mso-spacerun:yes'>&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>

<p class=a style='margin-left:0cm;text-align:justify;text-justify:inter-ideograph;
text-indent:18.0pt;mso-char-indent-count:2.0;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt;mso-fareast-font-family:仿宋_GB2312;mso-bidi-font-family:
"Times New Roman"'>#<span class=GramE>029<span style='mso-spacerun:yes'>&nbsp;
</span>%</span>&gt;<o:p></o:p></span></p>

<p class=MsoNormal style='text-indent:21.0pt'><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

</div>

</body>

</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -