Spring中ResponseEntity和HttpEntity有什么区别?

蒂姆·施瓦布(Tim Schwalbe)

我想知道两者之间的区别以及何时在SpringMVC Controller中使用它们。

提姆

阿卡什·罗伊(Akash Roy)

HttpEntity可用于创建RequestEntity和ResponseEntity。

其中,ResponseEntity是从HttpEntity继承的子类,其发送发送ResponseObject的方式更为复杂,并且仅限于发送Response。一些主要区别如下:

  1. 从HttpEntity继承的ResponseEntity在发送ResponseEntity对象时具有附加的HttpStatus代码。

  2. 它还具有将实体添加到响应对象的ResponseEntity.BodyBuilder和将标题添加到响应对象的ResponseEntity.HeadersBuilder。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章