Jersey(1.19.1) - Building Responses
2016-04-16 15:40
337 查看
Sometimes it is necessary to return additional information in response to a HTTP request. Such information may be built and returned using Response and Response.ResponseBuilder. For example, a common RESTful pattern for the creation of a new resource is to support a POST request that returns a 201 (Created) status code and a Location header whose value is the URI to the newly created resource. This may be achieved as follows:
In the above no representation produced is returned, this can be achieved by building an entity as part of the response as follows:
Response building provides other functionality such as setting the entity tag and last modified date of the representation.
@POST @Consumes("application/xml") public Response post(String content) { URI createdUri = ... create(content); return Response.created(createdUri).build(); }
In the above no representation produced is returned, this can be achieved by building an entity as part of the response as follows:
@POST @Consumes("application/xml") public Response post(String content) { URI createdUri = ... String createdContent = create(content); return Response.created(createdUri).entity(createdContent).build(); }
Response building provides other functionality such as setting the entity tag and last modified date of the representation.
相关文章推荐
- ngui中scrollview的使用
- 解决sui的Form表单验证回调问题
- UI 开发
- UIView中的坐标转换
- UI 开发
- SSM+EasyUI
- UI开发
- 关于PowerBuilder 9.0中如何修改项目工程名字
- Android 里子线程真的不能刷新UI吗?
- 《iOS Human Interface Guidelines》——Launch Files
- UI 布局
- iOS用ASIFormDataRequest实现图片上传
- 本地缓存以及UIDocumentInteractionController的使用
- UE4与WEB服务器交互(json)
- 【Arduino官方教程第一辑】示例程序 1-1 读取模拟信号、串口操作
- iOS 动画总结----UIView动画
- Android UI基础之Spinner
- UI- 五种手势识别总结
- poj 2264 Advanced Fruits lcs
- Android UI高级之Menu