Spring :Inserting cookies in a REST call response

后端 未结 5 1510
萌比男神i
萌比男神i 2020-12-16 17:45

I am implementing REST API endpoints using spring mvc. I am trying to send back a HTTP response with a cookie value. This is the equivalent of what I need

5条回答
  •  长情又很酷
    2020-12-16 18:46

    Alternatively you can use

    HttpHeaders headers = new HttpHeaders();
    headers.add(HttpHeaders.COOKIE, cookie-name + "=" + cookie value);
    ResponseEntity.status(HttpStatus.OK).headers(headers).build();
    

提交回复
热议问题