该页面的代码如下:
<table>
<%
List<User> list;
User user = new User();
try {
list = (List<User>) request.getAttribute("list");
%>
<%
for (int i = 0; i < list.size(); i++) {
user = list.get(i);
%>
<tr>
<td>
<input type="checkbox" name="check"
value="<%=user.getId()%>" />
</td>
<td>
<input type="hidden" value="<%=user.getId()%>" name="userId">
[color=#FF0000]<a href="html/updateUser.jsp">[/color]//这里跳转到另外一个页面,那么在跳转的页面中我如何获得当前的user对象呢
<%=user.getName()%></a>
</td>
<td><%=user.getDepartment()%></td>
<td><%=user.getTellNo()%></td>
</tr>
<%
}
} catch (Exception exception) {
%>
<tr></tr>
<%
}
%> </table>
<table>
<%
List<User> list;
User user = new User();
try {
list = (List<User>) request.getAttribute("list");
%>
<%
for (int i = 0; i < list.size(); i++) {
user = list.get(i);
%>
<tr>
<td>
<input type="checkbox" name="check"
value="<%=user.getId()%>" />
</td>
<td>
<input type="hidden" value="<%=user.getId()%>" name="userId">
[color=#FF0000]<a href="html/updateUser.jsp">[/color]//这里跳转到另外一个页面,那么在跳转的页面中我如何获得当前的user对象呢
<%=user.getName()%></a>
</td>
<td><%=user.getDepartment()%></td>
<td><%=user.getTellNo()%></td>
</tr>
<%
}
} catch (Exception exception) {
%>
<tr></tr>
<%
}
%> </table>
这一句会不会报空指针错误啊
其次 如果你处理好可以跳转的话 你可以在第二个页面用 opener.user来调用你页面1的对象以及方法
for(var i=0; i<xx--这里由后台传入; i++){
window.location.href="html/updateUser.jsp?tr1="+tableId.rows[i].cells[1].innerHTML;
}
}
放过去 updateUser.jsp中 ,然后在这个页面中根据userId来查到这个人的数据了
<input type="hidden" value="<%=user.getId()%>" name="userId">
<a href="html/updateUser.jsp?userid=<%=user.getId()%>"> <%=user.getName()%> </a>
</td>如上,后面的updateUser.jsp页面上:
String userid=request.getParameter("userid");
3楼的方法我也想到过,可是如何保存当前行的session呢? 给每个保存的session设置不同的名字?那跳转过去的页面又如何知道是哪个session呢