request.setAttribute("usernameError", "账号只能是字母或者数字");
valid=false;
}
if(StringUtils.isEmpty(password)){
request.setAttribute("passwordError", "密码不能为空");
valid=false;
}else if(password.length()>20){
request.setAttribute("passwordError", "密码长度不能大于20位");
valid=false;
}else if(password.length()<6){
request.setAttribute("passwordError", "密码长度不能小于6位");
valid=false;
}
if(!valid){
request.getRequestDispatcher("/login.jsp").forward(request, response);
return;
}
UserService userService = new UserService();
try{
User user = userService.getByUsername(username);
if(user==null){
throw new MyException("账号不存在");
}else if(!password.equals(user.getPassword())){
throw new MyException("密码不正确");
}
HttpSession session = request.getSession();
session.setAttribute("loginUser", user);
if("1".equals(user.getIsAdmin())){//管理员
request.getRequestDispatcher("/goodsMsg?operMethod=adminGoodsMsgList").forward(request, response);
}else{//普通用户
if("0".equals(user.getStatus())){
String operUrl = request.getParameter("operUrl");
request.setAttribute("operUrl", operUrl);
request.getRequestDispatcher("/loginSuccess.jsp").forward(request, response);
}else{
throw new MyException("账号已经删除");
} jsp+mysql大学校园二手交易平台开发+数据流图+ER图(11):http://www.751com.cn/jisuanji/lunwen_2112.html