esolve
V2EX  ›  问与答

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

  •  
  •   esolve · Dec 27, 2017 · 3289 views
    This topic created in 3069 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   ·   2838 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:55 · PVG 22:55 · LAX 07:55 · JFK 10:55
    ♥ Do have faith in what you're doing.