使用.load()检索参数
I have a jsp file: validate.jsp-
var rollNo=document.forms["result_form"]["studentRollno"].value;
var name=document.forms["result_form"]["studentName"].value;
$("#student_result").load("result.jsp?rollNo="+rollNo+"&name="+name);
As you can see, I am passing two data rollNo and name to result.jsp
Now in result.jsp:
String rollNo=request.getParameter("rollNo");
String name=request.getParameter("name");
out.print("Your roll number is: "+rollNo+"<br>");
out.print("Your name is: "+name);
Everything is fine. When I give rollNo=5 and name=something(in the textboxes in validate.jsp), result.jsp loads displaying the message as I intended. The only problem is, it works only as long as I don't give spaces in the textboxes!! For ex: If I enter name="Stalin", it works but for name="Stalin " and "Stalin Subramanaim", it doesn't work. result.jsp page doesn't load! Please help..!!
weixin_33695450
2012/06/20 17:28- jsp
- get
- parameters
- ajax
- jquery
- 点赞
- 收藏
- 回答