Spring security 什么';java安全框架的优势是什么?

Spring security 什么';java安全框架的优势是什么?,spring-security,shiro,Spring Security,Shiro,比较以将用户标识保存到会话,并使用侦听器进行授权 比如: 身份验证: 授权: 使用安全框架(如shiro或spring security)有什么好处?简言之,好处在于您可以以多快的速度将安全相关需求纳入项目中;基本的安全需求可能是权限管理和基于角色的授权,而更复杂的需求可能是跨平台会话管理 @RequestMapping("/checkLogin.do") public String checkLogin(Map map, HttpSession httpSession, String user

比较以将用户标识保存到会话,并使用侦听器进行授权

比如:

身份验证: 授权:
使用安全框架(如shiro或spring security)有什么好处?

简言之,好处在于您可以以多快的速度将安全相关需求纳入项目中;基本的安全需求可能是权限管理和基于角色的授权,而更复杂的需求可能是跨平台会话管理

@RequestMapping("/checkLogin.do")
public String checkLogin(Map map, HttpSession httpSession, String username, String password) {

    JSONObject userJson = userService.checkLogin(username, password);

    if ((Integer) userJson.get("success") == 0) {
        httpSession.setAttribute("userinfo", userJson);
        return "redirect:/index.do";
    } else {
        map.put("error", -1);
        return "login";
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse arg1, Object arg2) throws Exception {
        String requestURI = request.getRequestURI();
        HttpSession session = request.getSession();
        String userinfo= (String) session.getAttribute("userinfo");
        if (userinfo!= null) {
            return true;
        } else {
            arg1.sendRedirect("/login.do");
            return false;
        }

}