if (pwd==lostpwd) {
response.sendRedirect("updateSuccess.jsp");
ITeacherService teacher = new TeacherServiceImpl();
boolean result = teacher.UpdatePwdByUid(newpwd, id);
}else {
request.setAttribute("pwdError", "pwdError");
request.getRequestDispatcher("updatePwd.jsp").forward(request, response);
}
在做毕设教师信息查询系统的时候,做修改密码的时,原密码和登陆时的密码进行判断。
本来是用==来进行判断的,结果用debug看到直接跳到else里面去了。
后再网上找到string类型要用到equals来进行判断。就可以顺利运行了。
if (pwd.equals(lostpwd)) {
response.sendRedirect("updateSuccess.jsp");
ITeacherService teacher = new TeacherServiceImpl();
boolean result = teacher.UpdatePwdByUid(newpwd, id);
}else {
request.setAttribute("pwdError", "pwdError");
request.getRequestDispatcher("updatePwd.jsp").forward(request, response);
}