Spring @RestController not setting cookies with response
问题 I have the following rest endpoint that I would like to send a cookie along with my ResponseEntity . However after succesfully sending the response, the cookie is nowhere to be found. @RequestMapping(value = "myPath", method = RequestMethod.POST) public ResponseEntity<?> createToken(HttpServletResponse response) final String token = "a1b2c3d4e"; Cookie cookie = new Cookie("token", token); response.addCookie(cookie); // Return the token return ResponseEntity.ok(new MyCustomResponse(token)); }