世事如棋_2016
2016-11-04 15:18
String username="";
String password="";
request.setCharacterEncoding("utf-8");
username=request.getParameter("username");
password=request.getParameter("password");
if("admin".equals(username)&&"admin".equals(password)){
session.setAttribute("loginuser", username);
//request.getRequestDispatcher("login_success.jsp").forward(request, response);
}else{
//response.sendRedirect("login_failure.jsp");
}
%>
<%=session.getAttribute("username") %><br />
最后一句中的key改为<%=session.getAttribute("loginuser") %><br />,你在setAttribute时的key值为"loginuser",getAttribute取出来也应该是"loginuser"
JAVA遇见HTML——JSP篇
248277 学习 · 3071 问题
相似问题