esolve
V2EX  ›  问与答

Java :response.sendRedirect()如何能携带设定的 cookie?

  •  
  •   esolve · Dec 27, 2017 · 3294 views
    This topic created in 3076 days ago, the information mentioned may be changed or developed.

    如下

    Cookie cookie = new Cookie("JSESSIONID", jSessionId);
    cookie.setMaxAge(0);
    response.addCookie(cookie);   
    String redirectUrl = request.getContextPath() + Global.getAdminPath() +  "/doCancel";
    response.sendRedirect(redirectUrl);
    

    redirectUrl 是一个 springmvc 控制器的路径,指向一个模板 jsp 页面 在 chrome 调试看到,设定的 cookie 并没有带上 怎么回事?

    esolve
        1
    esolve  
    OP
       Dec 27, 2017
    顶顶顶
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   866 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 20:14 · PVG 04:14 · LAX 13:14 · JFK 16:14
    ♥ Do have faith in what you're doing.