这是我的代码
索引.html:
<html>
<head>
<script language="javascript">
var xmlHttp;
var f=1;
var t = "text";
function showState()
{
if (typeof XMLHttpRequest != "undefined"){
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp==null){
alert ("Browser does not support XMLHTTP Request");
return
}
var url="additem.jsp";
xmlHttp.onreadystatechange = stateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function stateChange(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById(t).innerHTML=xmlHttp.responseText;
t = "text"+f.toString();
f=f+1;
}
}
</script></head>
<body>
<center>
<form action=AddProd1.jsp method=post>
Enter Catagory <td><BLOCKQUOTE></BLOCKQUOTE><BLOCKQUOTE><center><input type=text name=catagory></BLOCKQUOTE></td>
</center>
<br><br>
<div id='text'></div><br>
<input type=submit value=Submit>
</form>
<input type=submit value=new onclick="showState();">
</body></html>
additem.jsp:
<jsp:useBean id="ob" class="te.tes" scope="session" />
<%!
String value = "";
String t = "" ;
String v="";
%>
<%
v=ob.Increase();
value = "product" + v;
t = "text" + v;
%>
<html>
<input type=text name=product value="<%=value%>">
<div id='<%=t%>'></div><br>
</html>
AddProd1.jsp:
<% int i;
String [] value = request.getParameterValues("product")
for(i=0;i<value.length;i++)
out.println(value[i]);
%>
无论我尝试什么,我都在 AddProd1.jsp 中的“value.length”中遇到异常......我什至试图通过只输入 request.getParameter("product") 来获得一个值......但我得到空值返回....我在做什么错???提前感谢..