jsp的问题,请各位高人帮俺看看,代码很短,不惹人烦
<input type= "hidden " name= "arg1 " value= "002 ">
<input type= "hidden " name= "arg2 " value= "2 ">
<%
String param1=request.getParameter( "arg1 ");
String param2=request.getParameter( "arg2 ");
out.println(param1);
out.println(param2);
%>
结果输出为null,这是怎么回事?如何在jsp中获得控件的参数值谢谢
------解决方案--------------------a.jsp
<form action= "b.jsp " method=post>
<input type= "hidden " name= "arg1 " value= "002 ">
<input type= "hidden " name= "arg2 " value= "2 ">
</form>
b.jsp
<%
String param1=request.getParameter( "arg1 ");
String param2=request.getParameter( "arg2 ");
out.println(param1);
out.println(param2);
%>
------解决方案--------------------这当然是null
你可以用jstl标签 <c:set> 来设置一个参数
<c:out> 输出
------解决方案--------------------大哥,你的表单有没有提交啊,
request.getParameter( "arg1 ");这个要提交之后才能取到值的
<form name= "form1 " method= "post ">
<input type= "hidden " name= "arg1 " value= "002 ">
<input type= "hidden " name= "arg2 " value= "2 ">
<input name= "Submit " type= "Submit " value= "提交 ">
</form>
<%
if(request.getMethod().equals( "POST "))
{
String param1=request.getParameter( "arg1 ");
String param2=request.getParameter( "arg2 ");
out.println(param1);
out.println(param2);
}
%>
------解决方案--------------------同意楼上!
表单都没有,怎么提交? 当然接收不到数据~~
建议楼主,还是多看看JSP方面的书籍!