Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsp 如果会话过期,如何在登录后重定向到工作页面_Jsp_Spring Mvc_Session - Fatal编程技术网

Jsp 如果会话过期,如何在登录后重定向到工作页面

Jsp 如果会话过期,如何在登录后重定向到工作页面,jsp,spring-mvc,session,Jsp,Spring Mvc,Session,你好,我在做会话处理,例如,在成功登录时,我使用正确的用户名和密码登录。我根据“记住我”复选框设置会话。然后,我将在仪表板上获取仪表板。我将在此处导航到userDetails.jsp。如果会话过期,则在再次登录后将重定向到login。我应如何重定向到userDetails.jsp 有人能告诉我如何使用spring安全性实现这一点吗 控制器 @RequestMapping(value = "/authenticate", method = RequestMethod.POST)

你好,我在做会话处理,例如,在成功登录时,我使用正确的用户名和密码登录。我根据“记住我”复选框设置会话。然后,我将在仪表板上获取仪表板。我将在此处导航到userDetails.jsp。如果会话过期,则在再次登录后将重定向到login。我应如何重定向到userDetails.jsp

有人能告诉我如何使用spring安全性实现这一点吗

控制器

  @RequestMapping(value = "/authenticate", method = RequestMethod.POST)
        public String loginAuthentication(@ModelAttribute("accountForm") Account account, ModelMap modelMap,
                HttpSession session, HttpServletRequest request, HttpServletResponse response) {

            AccountModel accountModel = new AccountModel();

            if (accountModel.login(account.getUsername(), account.getPassword())) {
                if (request.getParameter("remember") != null) {
                    session.setAttribute("username", account.getUsername());
                    session.setMaxInactiveInterval(100);
                    return "redirect:dashboard";
                } else {
                    session.setAttribute("username", account.getUsername());
                    session.setMaxInactiveInterval(30);
                    return "redirect:dashboard";
                }
            } else {
                modelMap.put("errorMSg", "invalid login");
                return "login";
            }

        }

    @RequestMapping(value = "/userDetails", method = RequestMethod.GET)
    public String checkPage(ModelMap modelMap, HttpSession session, HttpServletRequest request) {



        return "userDetails";
        }   

    @RequestMapping(value = "/dashboard", method = RequestMethod.GET )
    public String dashBoardPage(ModelMap modelMap, HttpSession session, HttpServletRequest request) {
        System.out.println("*********" + session.getAttribute("username"));
        System.out.println(count);
        if (session.getAttribute("username") == null) {
            modelMap.put("accountForm", new Account());
            return "loginPage";
        }
        return "dashBoardPage";
    }
userDetails.jsp

 <c:if test="${empty sessionScope.username}">
  <c:redirect url= "/login"/>
</c:if> 
  <c:if test="${empty sessionScope.username}">
      <c:redirect url= "/login"/>
    </c:if> 

<a href="userdetails">Userdetails</a>

dashBoard.jsp

 <c:if test="${empty sessionScope.username}">
  <c:redirect url= "/login"/>
</c:if> 
  <c:if test="${empty sessionScope.username}">
      <c:redirect url= "/login"/>
    </c:if> 

<a href="userdetails">Userdetails</a>