1
即時嘗試從jsp使用java腳本加載servlet。我也試圖傳遞兩個參數。該頁面加載,但現在我打印一個系統,它假設給我的id和車輛值,但它使車輛貓頭鷹空。從jsp加載servlet並嘗試傳遞多個參數
ScanServlet的doGet被稱爲ID = 1個車輛= [對象HTMLParagraphElement]車輛= NULL
這是代碼
<body onload="notifyOnLoad(<%=request.getParameter("imgid")%>)">
<img id="imgBarcode" src="ImageServlet?imgid=<%=request.getParameter("imgid")%>&vehicle=<%=request.getParameter("vehicle")%>" width=<%=request.getAttribute("Width")%> height=<%=request.getAttribute("Height")%>><br/>
<h4>Barcode Details</h4>
<p>Name :- <%=request.getAttribute("name")%></p>
<p>Type :- <%=request.getAttribute("type")%></p>
<p>Value :- <%=request.getAttribute("value")%></p>
<p id="wtf">type :- <%=request.getParameter("vehicle")%></p>
<script type="text/javascript">
function notifyOnLoad(imgid) {
var xmlhttp;
var vehicle =document.getElementById("wtf");
if(window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari;
xmlhttp = new XMLHttpRequest();
}
else{
/*code for IE6, IE5*/
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
window.location = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "ScanServlet?imgid="+imgid+"vehicle="+vehicle, true);
xmlhttp.send();
}
</script
>
</body>
我想傳遞兩個變量什麼是的語法?是該語法正確 xmlhttp.open( 「GET」, 「ScanServlet imgid =?」 + imgid + 「車輛=」 +車輛,TRUE); – 2014-10-30 06:55:24
更新了我的答案,檢查它:) – 2014-10-30 07:01:34
我更新了問題現在我得到一個新的錯誤請幫助 – 2014-10-30 09:10:18