login.jsp中加入以下测试代码
相关类从其它包中引入
<%
String command = request.getParameter("command");
if("login".equals(command)){
String userId = request.getParameter("userId");
String password = request.getParameter("password");
try{
//检查用户名密码是否存在,是否对应数据库中记录
User user = UserManager.getInstance().login(userId,password);
//用户信息设置到Session中
session.setAttribute("useinfo",user);
//设置session超时
session.setMaxInactiveInterval(60*60);
//重定向到main.jsp
response.sendRedirect(request.getContextPath()+"/main.jsp");
}catch(UserNotFoundExcepton e){
out.println(e.getMessage());
}catch(PasswordErrorException e){
out.println(e.getMessage());
}
}
%>
相关类从其它包中引入
<%
String command = request.getParameter("command");
if("login".equals(command)){
String userId = request.getParameter("userId");
String password = request.getParameter("password");
try{
//检查用户名密码是否存在,是否对应数据库中记录
User user = UserManager.getInstance().login(userId,password);
//用户信息设置到Session中
session.setAttribute("useinfo",user);
//设置session超时
session.setMaxInactiveInterval(60*60);
//重定向到main.jsp
response.sendRedirect(request.getContextPath()+"/main.jsp");
}catch(UserNotFoundExcepton e){
out.println(e.getMessage());
}catch(PasswordErrorException e){
out.println(e.getMessage());
}
}
%>