﻿<?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-liuzheng-文章分类-Ajax</title><link>http://www.blogjava.net/liuzheng/category/24914.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 30 Oct 2007 09:31:21 GMT</lastBuildDate><pubDate>Tue, 30 Oct 2007 09:31:21 GMT</pubDate><ttl>60</ttl><item><title>XML DOM object的通用创建方法</title><link>http://www.blogjava.net/liuzheng/articles/156657.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Mon, 29 Oct 2007 05:27:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/156657.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/156657.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/156657.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/156657.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/156657.html</trackback:ping><description><![CDATA[function createDocument() {<br />
var aVersions = [ "MSXML2.DOMDocument.5.0",<br />
"MSXML2.DOMDocument.4.0"," MSXML2.DOMDocument.3.0",<br />
"MSXML2.DOMDocument"," Microsoft.XmlDom"<br />
];<br />
for (var i = 0; i &lt; aVersions.length; i++) {<br />
try {<br />
var oXmlDom = new ActiveXObject(aVersions[i]);<br />
return oXmlDom;<br />
} catch (oError) {<br />
//Do nothing<br />
}<br />
}<br />
throw new Error("MSXML is not installed.");<br />
}<br />
<br />
<br />
使用如下：<br />
var oXmlDom = createDocument();
<img src ="http://www.blogjava.net/liuzheng/aggbug/156657.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2007-10-29 13:27 <a href="http://www.blogjava.net/liuzheng/articles/156657.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>创建XMLlHttp的通用方法</title><link>http://www.blogjava.net/liuzheng/articles/156624.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Mon, 29 Oct 2007 03:36:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/156624.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/156624.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/156624.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/156624.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/156624.html</trackback:ping><description><![CDATA[function createXMLHttp() {<br />
if (typeof XMLHttpRequest != "undefined") {<br />
return new XMLHttpRequest();<br />
} else if (window.ActiveXObject) {<br />
var aVersions = [ "MSXML2.XMLHttp.5.0",<br />
"MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",<br />
"MSXML2.XMLHttp","Microsoft.XMLHttp"<br />
];<br />
for (var i = 0; i &lt; aVersions.length; i++) {<br />
try {<br />
var oXmlHttp = new ActiveXObject(aVersions[i]);<br />
return oXmlHttp;<br />
} catch (oError) {<br />
//Do nothing<br />
}<br />
}<br />
}<br />
throw new Error("XMLHttp object could be created.");<br />
} <br />
<br />
<br />
<br />
使用如下：<br />
var oXmlHttp = createXMLHttp() ；
<img src ="http://www.blogjava.net/liuzheng/aggbug/156624.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2007-10-29 11:36 <a href="http://www.blogjava.net/liuzheng/articles/156624.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Advantages and Disadvantages of XMLHttp</title><link>http://www.blogjava.net/liuzheng/articles/156610.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Mon, 29 Oct 2007 02:50:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/156610.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/156610.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/156610.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/156610.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/156610.html</trackback:ping><description><![CDATA[Undoubtedly, you can see the advantage of using XMLHttp for client-server communication instead of hidden frames. The code you write is much cleaner and the intent of the code is much more apparent than using numerous callback functions with hidden frames. You have access to request and response headers as well as HTTP status codes, enabling you to determine if your request was successful.<br />
The downside is that, unlike hidden frames, there is no browser history record of the calls that were made. The Back and Forward buttons do not tie in to XMLHttp requests, so you have effectively cut off their use. It is for this reason that many Ajax applications use a mixture of XMLHttp and hidden frames to make a truly usable interface.<br />
Another disadvantage, which applies to Internet Explorer only, is that you depend on ActiveX controls being enabled. If the user has your page set up in a particular security zone that doesn't allow ActiveX controls, you cannot access the XMLHttp object. In that case, you may have to default to using hidden frames.
<img src ="http://www.blogjava.net/liuzheng/aggbug/156610.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2007-10-29 10:50 <a href="http://www.blogjava.net/liuzheng/articles/156610.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Advantages and Disadvantages of Hidden Frames</title><link>http://www.blogjava.net/liuzheng/articles/156600.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Mon, 29 Oct 2007 02:23:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/156600.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/156600.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/156600.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/156600.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/156600.html</trackback:ping><description><![CDATA[Hidden Frames Technology is the&nbsp;farther of the Ajax<br />
Now that you have seen the powerful things that you can do using hidden frames, it's time to discuss the practicality of using them. As mentioned previously, this technique has been around for many years and is still used in many Ajax applications.<br />
One of the biggest arguments for using hidden frames is that you can maintain the browser history and thus enable users to still use the Back and Forward buttons in the browser. Because the browser doesn't know that a hidden frame is, in fact, hidden, it keeps track of all the requests made through it. Whereas the main page of an Ajax application may not change, the changes in the hidden frame mean that the Back and Forward buttons will move through the history of that frame instead of the main page. This technique is used in both Gmail and Google Maps for this very reason.<br />
The downside of hidden frames is that there is very little information about what's going on behind the scenes. You are completely reliant on the proper page being returned. The examples in this section all had the same problem: If the hidden frame page failed to load, there is no notification to the user that a problem has occurred; the main page will continue to wait until the appropriate JavaScript function is called. You may be able to provide some comfort to a user by setting a timeout for a long period of time, maybe five minutes, and displaying a message if the page hasn't loaded by then, but that's just a workaround. The main problem is that you don't have enough information about the HTTP request that is happening behind the scenes. Fortunately, there is another option.
<img src ="http://www.blogjava.net/liuzheng/aggbug/156600.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2007-10-29 10:23 <a href="http://www.blogjava.net/liuzheng/articles/156600.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>二级联动菜单代码</title><link>http://www.blogjava.net/liuzheng/articles/136664.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Tue, 14 Aug 2007 06:32:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/136664.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/136664.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/136664.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/136664.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/136664.html</trackback:ping><description><![CDATA[<div class="subtable altbg2 t_msg" style="WIDTH: auto; HEIGHT: auto"><strong>二级联动菜单代码(AJAX+JAVA)</strong><br><br>做项目经常要用到的,现在只给出一个不用数据库的代码,可作参考:<br>/**<br>*category.jsp 含有AJAX程序<br>*<br>*/<br>[java]<br>&lt;%@ page language="java" pageEncoding="UTF-8"%&gt;<br>&lt;html&gt; <br>&nbsp;&nbsp;&lt;head&gt;<br>&nbsp; &nbsp; &lt;title&gt;二级菜单联动演示&lt;/title&gt;<br>&nbsp;&nbsp;&lt;script type="text/javascript"&gt;<br>&nbsp; &nbsp; var req;<br>&nbsp; &nbsp; window.onload=function(){//页面加载时的函数<br><br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; function Change_Select(){//当第一个下拉框的选项发生改变时调用该函数<br>&nbsp; &nbsp;&nbsp; &nbsp;var zhi = document.getElementById('hero').value;<br>&nbsp; &nbsp;&nbsp; &nbsp;var url = "servlet/select?id="+ escape(zhi);<br>&nbsp; &nbsp;&nbsp; &nbsp;if(window.XMLHttpRequest){<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;req = new XMLHttpRequest();<br>&nbsp; &nbsp;&nbsp; &nbsp;}else if(window.ActiveXObject){<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;req = new ActiveXObject("Microsoft.XMLHTTP");<br>&nbsp; &nbsp;&nbsp; &nbsp;}<br>&nbsp; &nbsp;&nbsp; &nbsp;<br>&nbsp; &nbsp;&nbsp; &nbsp;if(req){<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;req.open("GET",url,true);<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;req.onreadystatechange = callback; //指定回调函数为callback<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;req.send(null);<br>&nbsp; &nbsp;&nbsp; &nbsp;}<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; function callback(){<br>&nbsp; &nbsp;&nbsp; &nbsp;if(req.readyState ==4){<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if(req.status ==200){<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; parseMessage();//解析XML文档<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}else{<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; alert("Not able to retrieve description" + req.statusText);<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br>&nbsp; &nbsp;&nbsp; &nbsp;}<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; function parseMessage(){<br>&nbsp; &nbsp;&nbsp; &nbsp;var xmlDoc = req.responseXML.documentElement;//获得返回的XML文档<br>&nbsp; &nbsp;&nbsp; &nbsp;var xSel = xmlDoc.getElementsByTagName('select');<br>&nbsp; &nbsp;&nbsp; &nbsp;//获得XML文档中的所有&lt;select&gt;标记<br>&nbsp; &nbsp;&nbsp; &nbsp;var select_root = document.getElementById('skill');<br>&nbsp; &nbsp;&nbsp; &nbsp;//获得网页中的第二个下拉框<br>&nbsp; &nbsp;&nbsp; &nbsp;select_root.options.length=0;<br>&nbsp; &nbsp;&nbsp; &nbsp;//每次获得新的数据的时候先把每二个下拉框架的长度清0<br>&nbsp; &nbsp;&nbsp; &nbsp;<br>&nbsp; &nbsp;&nbsp; &nbsp;for(var i=0;i&lt;xSel.length;i++){<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var xValue = xSel[i].childNodes[0].firstChild.nodeValue;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;//获得每个&lt;select&gt;标记中的第一个标记的值,也就是&lt;value&gt;标记的值<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var xText = xSel[i].childNodes[1].firstChild.nodeValue;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;//获得每个&lt;select&gt;标记中的第二个标记的值,也就是&lt;text&gt;标记的值<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var option = new Option(xText, xValue);<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;//根据每组value和text标记的值创建一个option对象<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;try{<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; select_root.add(option);//将option对象添加到第二个下拉框中<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}catch(e){<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br>&nbsp; &nbsp;&nbsp; &nbsp;}<br>&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&lt;/script&gt;<br>&nbsp;&nbsp;&lt;/head&gt;<br><br>&nbsp;&nbsp;&lt;body&gt;<br>&nbsp;&nbsp;&lt;div align="center"&gt;<br>&nbsp;&nbsp;&lt;form name="form1" method="post" action=""&gt;<br>&nbsp;&nbsp;&lt;table width="70%" border="0" cellspacing="0" cellpadding="0"&gt;<br>&nbsp; &nbsp; &lt;tr&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&lt;td align="center"&gt;Double Select Box&lt;/td&gt;<br>&nbsp; &nbsp; &lt;/tr&gt;<br>&nbsp; &nbsp; &lt;tr&gt;<br>&nbsp; &nbsp; &lt;td&gt;<br>&nbsp; &nbsp; &lt;select name="hero" id="hero" onChange="Change_Select()"&gt;<br>&nbsp; &nbsp; &lt;!--第一个下拉菜单--&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&lt;option value="0"&gt;Unbounded&lt;/option&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&lt;option value="1"&gt;D.K. &lt;/option&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&lt;option value="2"&gt;NEC. &lt;/option&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&lt;option value="3"&gt;BOSS &lt;/option&gt;<br>&nbsp; &nbsp; &lt;/select&gt;<br>&nbsp; &nbsp; &lt;select name="skill" id="skill"&gt;<br>&nbsp; &nbsp; &lt;!--第二个下拉菜单--&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&lt;option value="0"&gt;Unbounded&lt;/option&gt;<br>&nbsp; &nbsp; &lt;/select&gt;<br>&nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &lt;/tr&gt;<br>&nbsp; &nbsp; &lt;tr&gt;<br>&nbsp; &nbsp; &lt;td&gt; &lt;/td&gt;<br>&nbsp; &nbsp; &lt;tr&gt;<br>&nbsp; &nbsp; &lt;/table&gt;<br>&nbsp;&nbsp;&lt;/form&gt;<br>&nbsp;&nbsp;&lt;/div&gt;<br>&nbsp;&nbsp;&lt;/body&gt;<br>&lt;/html&gt;<br>[/java]</div>
<br>
<div class="simpletable smalltxt" style="WIDTH: 100%">
<div class="subtable altbg1"><span class=right>2007-3-27 15:00</span> <strong>bufegar</strong></div>
<div class="subtable altbg2 t_msg" style="WIDTH: auto; HEIGHT: auto">/**<br>*SelectServelet.java 处理页面返回的数据,返回XML给AJAX使用<br>*<br>*/<br><br>[java]<br>package onlinetest.servlet;<br><br>import java.io.IOException;<br><br>import javax.servlet.ServletException;<br>import javax.servlet.http.HttpServlet;<br>import javax.servlet.http.HttpServletRequest;<br>import javax.servlet.http.HttpServletResponse;<br><br>public class SelectServlet extends HttpServlet {<br><br>&nbsp;&nbsp;/**<br>&nbsp; &nbsp;* The doGet method of the servlet. &lt;br&gt;<br>&nbsp; &nbsp;* <br>&nbsp; &nbsp;* This method is called when a form has its tag value method equals to get.<br>&nbsp; &nbsp;* <br>&nbsp; &nbsp;* @param request<br>&nbsp; &nbsp;*&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;the request send by the client to the server<br>&nbsp; &nbsp;* @param response<br>&nbsp; &nbsp;*&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;the response send by the server to the client<br>&nbsp; &nbsp;* @throws ServletException<br>&nbsp; &nbsp;*&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if an error occurred<br>&nbsp; &nbsp;* @throws IOException<br>&nbsp; &nbsp;*&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if an error occurred<br>&nbsp; &nbsp;*/<br>&nbsp;&nbsp;public void doGet(HttpServletRequest request, HttpServletResponse response)<br>&nbsp; &nbsp;&nbsp; &nbsp;throws ServletException, IOException {<br>&nbsp; &nbsp; response.setContentType("text/xml");<br>&nbsp; &nbsp; response.setHeader("Cache-Control", "no-cache");<br>&nbsp; &nbsp; String targetId = request.getParameter("id").toString();<br>&nbsp; &nbsp; // 获得请求中参数为id的值<br>&nbsp; &nbsp; String xml_start = "&lt;selects&gt;";<br>&nbsp; &nbsp; String xml_end = "&lt;/selects&gt;";<br>&nbsp; &nbsp; String xml = "";<br><br>&nbsp; &nbsp; if (targetId.equalsIgnoreCase("0")) {<br>&nbsp; &nbsp;&nbsp; &nbsp;xml = "&lt;select&gt;&lt;value&gt;0&lt;/value&gt;&lt;text&gt;Unbounded&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp; } else if (targetId.equalsIgnoreCase("1")) {<br>&nbsp; &nbsp;&nbsp; &nbsp;xml = "&lt;select&gt;&lt;value&gt;1&lt;/value&gt;&lt;text&gt;Mana Burn&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp;&nbsp; &nbsp;xml += "&lt;select&gt;&lt;value&gt;2&lt;/value&gt;&lt;text&gt;Death Coil&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp;&nbsp; &nbsp;xml += "&lt;select&gt;&lt;value&gt;3&lt;/value&gt;&lt;text&gt;Unhkly Aura&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp;&nbsp; &nbsp;xml += "&lt;select&gt;&lt;value&gt;4&lt;/value&gt;&lt;text&gt;Unholy Fire&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp; } else if (targetId.equalsIgnoreCase("2")) {<br>&nbsp; &nbsp;&nbsp; &nbsp;xml = "&lt;select&gt;&lt;value&gt;1&lt;/value&gt;&lt;text&gt;Corpexplode&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp;&nbsp; &nbsp;xml += "&lt;select&gt;&lt;value&gt;2&lt;/value&gt;&lt;text&gt;Raise Dead&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp;&nbsp; &nbsp;xml += "&lt;select&gt;&lt;value&gt;3&lt;/value&gt;&lt;text&gt;Brilliance Aura&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp;&nbsp; &nbsp;xml += "&lt;select&gt;&lt;value&gt;4&lt;/value&gt;&lt;text&gt;Aim Aura&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp; } else {// 如果是3,则返回下面的字符<br>&nbsp; &nbsp;&nbsp; &nbsp;xml = "&lt;select&gt;&lt;value&gt;1&lt;/value&gt;&lt;text&gt;Rain of Chaos&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp;&nbsp; &nbsp;xml += "&lt;select&gt;&lt;value&gt;2&lt;/value&gt;&lt;text&gt;Finger of Death&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp;&nbsp; &nbsp;xml += "&lt;select&gt;&lt;value&gt;3&lt;/value&gt;&lt;text&gt;Bash&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp;&nbsp; &nbsp;xml += "&lt;select&gt;&lt;value&gt;4&lt;/value&gt;&lt;text&gt;Summon Doom&lt;/text&gt;&lt;/select&gt;";<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp; String last_xml = xml_start + xml + xml_end;<br>&nbsp; &nbsp; response.getWriter().write(last_xml);<br><br>&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;/**<br>&nbsp; &nbsp;* The doPost method of the servlet. &lt;br&gt;<br>&nbsp; &nbsp;* <br>&nbsp; &nbsp;* This method is called when a form has its tag value method equals to<br>&nbsp; &nbsp;* post.<br>&nbsp; &nbsp;* <br>&nbsp; &nbsp;* @param request<br>&nbsp; &nbsp;*&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;the request send by the client to the server<br>&nbsp; &nbsp;* @param response<br>&nbsp; &nbsp;*&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;the response send by the server to the client<br>&nbsp; &nbsp;* @throws ServletException<br>&nbsp; &nbsp;*&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if an error occurred<br>&nbsp; &nbsp;* @throws IOException<br>&nbsp; &nbsp;*&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if an error occurred<br>&nbsp; &nbsp;*/<br>&nbsp;&nbsp;public void doPost(HttpServletRequest request, HttpServletResponse response)<br>&nbsp; &nbsp;&nbsp; &nbsp;throws ServletException, IOException {<br><br>&nbsp; &nbsp; doGet(request, response);// 对于post的请求方式和get请求方式一样处理<br>&nbsp;&nbsp;}<br><br>}<br>[/java]</div>
</div>
<br>
<div class="simpletable smalltxt" style="WIDTH: 100%">
<div class="subtable altbg1"><span class=right>2007-3-27 15:02</span> <strong>bufegar</strong></div>
<div class="subtable altbg2 t_msg" style="WIDTH: auto; HEIGHT: auto">/**<br>*web.xml 配置Servlet,可以使用MyEclipse创建Servlet,自动生成web.xml<br>*<br>*/<br><br>[xml]<br>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>&lt;web-app xmlns="&lt;a href="http://java.sun.com/xml/ns/j2ee"" target="_blank"&gt;[url]http://java.sun.com/xml/ns/j2ee[/url]"&lt;/a&gt; xmlns:xsi="&lt;a href="http://www.w3.org/2001/XMLSchema-instance"" target="_blank"&gt;[url]http://www.w3.org/2001/XMLSchema-instance[/url]"&lt;/a&gt; version="2.4" xsi:schemaLocation="&lt;a href="http://java.sun.com/xml/ns/j2ee" target="_blank"&gt;[url]http://java.sun.com/xml/ns/j2ee[/url]&lt;/a&gt;&nbsp; &nbsp;&lt;a href="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;" target="_blank"&gt;[url]http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd[/url]"&gt;&lt;/a&gt;<br>&nbsp;&nbsp;&lt;servlet&gt;<br>&nbsp; &nbsp; &lt;servlet-name&gt;select&lt;/servlet-name&gt;<br>&nbsp; &nbsp; &lt;servlet-class&gt;onlinetest.servlet.SelectServlet&lt;/servlet-class&gt;<br>&nbsp;&nbsp;&lt;/servlet&gt;<br><br>&nbsp;&nbsp;&lt;servlet-mapping&gt;<br>&nbsp; &nbsp; &lt;servlet-name&gt;select&lt;/servlet-name&gt;<br>&nbsp; &nbsp; &lt;url-pattern&gt;/servlet/select&lt;/url-pattern&gt;<br>&nbsp;&nbsp;&lt;/servlet-mapping&gt;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;&lt;filter&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;filter-name&gt;characterFilter&lt;/filter-name&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;filter-class&gt;filters.SetCharacterEncodingFilter&lt;/filter-class&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;init-param&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;param-name&gt;encoding&lt;/param-name&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;param-value&gt;utf-8&lt;/param-value&gt;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;/init-param&gt;<br>&nbsp; &nbsp; &lt;/filter&gt;<br>&nbsp; &nbsp;&lt;filter-mapping&gt;<br>&nbsp; &nbsp; &lt;filter-name&gt;characterFilter&lt;/filter-name&gt;<br>&nbsp; &nbsp; &lt;url-pattern&gt;/*&lt;/url-pattern&gt;<br>&nbsp; &nbsp;&lt;/filter-mapping&gt;<br>&lt;/web-app&gt;[/xml]<br><br>原文地址:[url]http://my.boolean.cn/read.php?130&amp;part=3[/url]</div>
</div>
<img src ="http://www.blogjava.net/liuzheng/aggbug/136664.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2007-08-14 14:32 <a href="http://www.blogjava.net/liuzheng/articles/136664.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>