日期:2014-05-18  浏览次数:20800 次

一个servlet返回的问题
一个jsp页面.a.jsp,一个form表单提交到submit这个servlet
<form   name= "submit "   method= "POST "   action= "submit ">
<input   type= "input "   name= "test "   value= "1 ">
<input   type= "submit "   name= "submit "   value= "submit ">
</form>
当我submit这个servlet处理完之后用这个语句继续返回这个jsp页面
getServletContext().getRequestDispatcher( "a.jsp ").include(request,   response);
第一个问题:那么是不是request里面还有一个test的参数,其值为1?
因为a.jsp里还有一个form,
<form   name= "submit2 "   method= "post "   action= "submit2 ">
<input   type= "submit "   name= "submit2 "   value= "submit2 ">
<form>
那个这个form提交到submit2这个servlet的时候,是否可以用
request.getParameter( "test ")来得到test的值?
我试过了,得不到。
那应该用什么方法可以得到上面那个form的值呢?
或者说怎么设计合理一点?

------解决方案--------------------
<form name= "submit " method= "POST " action= "submit ">
<input type= "text " name= "test " value= "1 ">
<input type= "submit " name= "submit " value= "submit ">
</form>
<form name= "submit2 " method= "post " action= "submit2 ">
<input type= "text " name= "test2 " value= " <%=request.getParameter( "test ")%> ">
<input type= "submit " name= "submit2 " value= "submit2 ">
<form>

submit