Guest User

Untitled

a guest
May 24th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. @RequestMapping("/checkLogin.do")
  2. public String checkLogin(Map map, HttpSession httpSession, String username, String password) {
  3.  
  4. JSONObject userJson = userService.checkLogin(username, password);
  5.  
  6. if ((Integer) userJson.get("success") == 0) {
  7. httpSession.setAttribute("userinfo", userJson);
  8. return "redirect:/index.do";
  9. } else {
  10. map.put("error", -1);
  11. return "login";
  12. }
  13.  
  14. @Override
  15. public boolean preHandle(HttpServletRequest request, HttpServletResponse arg1, Object arg2) throws Exception {
  16. String requestURI = request.getRequestURI();
  17. HttpSession session = request.getSession();
  18. String userinfo= (String) session.getAttribute("userinfo");
  19. if (userinfo!= null) {
  20. return true;
  21. } else {
  22. arg1.sendRedirect("/login.do");
  23. return false;
  24. }
  25.  
  26. }
Add Comment
Please, Sign In to add comment