后台登录显示账户密码错误?
来源:4-6 运营后台管理员模块(下)
Ari_wuhan
2023-03-09
我的账户和密码是在applications.properties中设置为:
#admin官方账号用户名和密码
admin.email=admin@hut.com
admin.encryptPassword=4QrcOUm6Wau+VuBX8g+IPg==
#密码为123456
AdminController.java中:
@RequestMapping(value = “/login”,method = RequestMethod.POST)
public String login(@RequestParam(name=“email”)String email,
@RequestParam(name=“password”)String password ) throws BusinessException, UnsupportedEncodingException, NoSuchAlgorithmException {
if (StringUtils.isEmptyOrWhitespaceOnly(email) || StringUtils.isEmptyOrWhitespaceOnly(password)) {
throw new BusinessException(EmBusinessError.PARAMETER_VALIDATION_ERROR, “用户名密码不能为空”);
}
if(email.equals(this.email) && encodeByMd5(password).equals(this.encryptPassword)){
//登录成功
httpServletRequest.getSession().setAttribute(CURRENT_ADMIN_SESSION,email);
return “redirect:/admin/admin/index”;
}else{
throw new BusinessException(EmBusinessError.PARAMETER_VALIDATION_ERROR,“用户名密码错误”);
}
}
与老师不同的只是isEmpty是isEmptyOrWhitespaceOnly。因为现在已经没有isEmpy方法了。
但是我登录时候,还是显示账号密码错误。
1回答
-
debug下代码定位下具体问题
012023-03-09
相似问题