在JSP頁面中我已經寫:如何從JSP獲取Servlet中的JSON對象?
var sel = document.getElementById("Wimax");
var ip = sel.options[sel.selectedIndex].value;
var param;
var url = 'ConfigurationServlet?ActionID=Configuration_Physical_Get';
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
httpRequest.open("POST", url, true);
httpRequest.onreadystatechange = handler(){
if (httpRequest.readyState == 4) {
if (httpRequest.status == 200) {
param = 'ip='+ip;
param += 'mmv='+mmv;
param += "tab="+tab;
}};
httpRequest.send(param);
我想在我的ConfigurationServlet
這個param
變量。任何人都可以告訴我如何讓這個json對象在servlet中?
更新:我改變了我的發言,現在它顯示狀態碼200
var index = document.getElementById("Wimax").selectedIndex;
var ip = document.getElementById("Wimax").options[index].text;
httpReq = GetXmlHttpObject();
alert(httpReq);
var param = "ip=" + ip;
param += "&mmv=" + mmv;
param += "&tab=" + tab;
alert("param "+param);
var url="http://localhost:8080/WiMaxNM/ConfigurationServlet?ActionID=Configuration_Physical_Get";
url = url+"?"+param;
httpReq.open("GET",url,true);
alert("httpReq "+httpReq);
httpReq.onreadystatechange = handler;
httpReq.send(null);
但新的問題又發生。控制根本不會按照url中指定的servlet操作ID進行。請告訴我這裏有什麼問題。
對於使用HttpServletRequest#getParameter(),我必須給隱藏id param然後document.form id.submit。而不是我不能通過ActiveXObject()的對象得到它? – divi 2010-05-04 12:05:53
我不明白你的意思。請直接爲你自己解決。在w3schools.com是學習Ajax平凡的很好的教程,在Coreservlets.com上是學習Servlet平凡的很好的教程。 – BalusC 2010-05-04 12:18:23
好吧BalusC.but還有一個問題,我有。我的應用程序顯示狀態代碼= 500(內部服務器錯誤)。你能爲此建議我嗎? – divi 2010-05-05 10:53:15