Spring :Inserting cookies in a REST call response

后端 未结 5 1505
萌比男神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:28

    I finally found the solution :

    HttpHeaders headers = new HttpHeaders();
    headers.add("Set-Cookie","key="+"value");
    ResponseEntity.status(HttpStatus.OK).headers(headers).build();
    

提交回复
热议问题