Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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;
- }
- }
Add Comment
Please, Sign In to add comment