首页 > 解决方案 > Response 实体中 replaceAll(Response) 的替换是什么?

问题描述

响应有replaceAll,它采用标头(类型:MultivaluedMap)。

如果我想使用 ResponseEntity,等效代码是什么?

响应 .ResponseBuilder .entity(entityValue) .replaceAll(headers) .type(APPLICATION_JSON) .build();

标签: springspring-bootspring-rest

解决方案


您可以使用构造函数:

new ResponseEntity<>(headers, HttpStatus.OK);

headers 是一个"MultiValueMap headers"


推荐阅读