spring - Response 实体中 replaceAll(Response) 的替换是什么?
问题描述
响应有replaceAll,它采用标头(类型:MultivaluedMap)。
如果我想使用 ResponseEntity,等效代码是什么?
响应 .ResponseBuilder .entity(entityValue) .replaceAll(headers) .type(APPLICATION_JSON) .build();
解决方案
您可以使用构造函数:
new ResponseEntity<>(headers, HttpStatus.OK);
headers 是一个"MultiValueMap headers"。
推荐阅读
- c - 如何在 if 语句中打破嵌套 for 循环并在满足其他 If 条件时切换到另一个语句?
- dart - 如何在扩展方法中使用运算符?
- c# - 如何使用 C# 将模式匹配的 XML 元素序列化为列表
- excel - excel中函数输入的总和
- azure - Azure Data Lake Storage (ADLS Gen2) 中的 java.lang.NoSuchMethodError: reactor.core.publisher.Flux.toIterable(I)Ljava/lang/Iterable"
- python - 如何使用键输入在 Pyglet 中移动对象
- python-3.x - 如何通过输入/答案在 Python 中产生打字效果?
- rspec - 确定为什么 bundler 加载文件需要这么长时间?
- python - 如何使用 pytest、fastapi 和 tortoise-orm 回滚每个测试?
- python - Squarespace 使用 curl 和 python 不返回任何数据