值传递问题
int id;
int rootid;
try{
id = Integer.parseInt(idStr);//这里是从上一个页面传过来的值
rootid = Integer.parseInt(rootidStr);//这里是从上一个页面传过来的值
} catch (NumberFormatException e){
out.println("Error NumberFormat");//catch Exception的处理
return;
}
然后我在下面的代码中,把这两个值(id 和 rootid)在链接的后面,想通过类似于
<a href="replyOk.jsp?id=<%=id%>&rootid=<%rootid%>" />
这样的方式传递的下一个页面。
结果下一个页面收到的参数为空。
一直搞不懂为什么,不过只要在声明id和rootid的时候,像下面这样
int id = 0;
int rootid = 0;
这样就可以正常传递过去了,搞不懂为什么,以后复习的时候再来解决。
2017/8/23 修改
不对不对,还是传不过去,贴上全部代码
<%
int id;
int rootid;
try{
id = Integer.parseInt(idStr);//这里是从上一个页面传过来的值
rootid = Integer.parseInt(rootidStr);//这里是从上一个页面传过来的值
} catch (NumberFormatException e){
out.println("Error NumberFormat");//catch Exception的处理
return;
%>
<form name=reply action="replyOK.jsp?pid=<%=id %>&rootid=<%=rootid %>" method="get">
//方式一
想通方式一传过去下一个页面,发现下一个页面收到的是空值(null).
<form name=reply action="replyOK.jsp" method="get">
<input type="hidden" name="pid" value="<%=id %>">
<input type="hidden" name="rootid" value="<%=rootid %>">
//方式二
方式二没问题,觉得好奇怪