setAttribute与getAttribute问题
程序代码:
<%@ page language="java" import="java.util.*,java.sql.*,com.tk.model.*" pageEncoding="gb2312"%> <html> <head> <title>My JSP 'wel.jsp' starting page</title> </head> <body> 登录成功! <%=request.getAttribute("user") %><br/> <a href="login.jsp">返回重新登录</a> <hr/> <h1>用户信息列表</h1> <% //UserBeanCl ubc=new UserBeanCl(); //ArrayList al=ubc.getUsersByPage(pageNow); ArrayList al=(ArrayList)request.getAttribute("result"); //显示 %> <table border="1"> <tr><td>用户id</td><td>用户名</td><td>密码</td><td>电子邮件</td><td>级别</td></tr> <% for(int i=0;i<al.size();i++){ UserBean ub=(UserBean)al.get(i); %> <tr><td><%=ub.getUserId() %></td><td><%=ub.getUsername() %></td><td><%=ub.getPasswd() %></td><td><%=ub.getEmail() %></td><td><%=ub.getGrade() %></td></tr> <% } %> </table> <% int pageNow=Integer.parseInt((String)request.getAttribute("pageNow")); if(pageNow!=1){ out.println("<a href=UserClServlet?pageNow="+(pageNow-1)+">上一页</a>"); } //显示超链接 String s_pageCount=(String)request.getAttribute("pageCount"); int pageCount=Integer.parseInt(s_pageCount); for(int i=1;i<=pageCount;i++){ out.println("<a href=UserClServlet?pageNow="+i+">["+i+"]</a>"); } if(pageNow!=pageCount){ out.println("<a href=UserClServlet?pageNow="+(pageNow+1)+">下一页</a>"); } %> </body> </html> 为什么当第一次加载的时候有用户名,点击第二页,第三页后就没有了用户名!!!