如标题,用spring mvc 4.3.2+mybatis 3.4.1 + mysql 5.7.14 +shiro 开发了一个用于幼儿园的管理系统。

  功能模块 包括 账号,角色,权限管理。 幼儿档案管理, 幼儿收费管理等。 权限方面采用了shiro的权限控制,感觉还是蛮强大的。我的理念是 简单,够用就好。

前端框架是基于H-ui.admin的模板来开发的。这个模板用起来还是蛮方便的,适合对前端不是很熟的人采用,可以达到专业的效果。赞一个。

先截个图

spring mvc 4.3.2 + mybatis 3.4.1 + mysql 5.7.14 +shiro 幼儿园收费系统 之 登录-LMLPHP

实现要点,前端用js把密码用md5加密后传给后台。 防止密码明文传送。

后台controller 实现要点, 采用 shiro 的密码验证。

    @RequestMapping(value="/login",method=RequestMethod.POST)
public String login(@ModelAttribute LoginDto login,
HttpServletRequest request,Model model,
BindingResult bindingResult,
RedirectAttributes redirectAttributes){
try {
logger.info("login is:"+JSON.toJSONString(login)); String code = (String) request.getSession().getAttribute("code"); if (code != null && !code.equalsIgnoreCase(login.getCode())){
model.addAttribute("error","验证码错误");
model.addAttribute("LoginDto",login);
return "/login";
} if(bindingResult.hasErrors()){
return "/login";
}
//使用权限工具进行用户登录,登录成功后跳到shiro配置的successUrl中,与下面的return没什么关系!
UsernamePasswordToken token = new UsernamePasswordToken(login.getUserName(), login.getPassword());
if (login.getRememberMe() == null){
login.setRememberMe(false);
}
token.setRememberMe(login.getRememberMe());
SecurityUtils.getSubject().login(token); return "redirect:/";
} catch (AuthenticationException e) {
//redirectAttributes.addFlashAttribute("message","用户名或密码错误");
model.addAttribute("error","用户名或密码错误");
model.addAttribute("LoginDto",login);
return "/login";
}

  

05-01 05:29