zoukankan      html  css  js  c++  java
  • Jersey(1.19.1)

    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:

    @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.

  • 相关阅读:
    Java面向对象——属性赋值的过程
    Java面向对象——类的成员之三:构造器(构造方法)constructor
    课后作业—5
    缓冲类的使用示例
    缓冲技术
    流的基类
    流的分类
    什么是流?
    关于开发中异常处理的建议
    阅读笔记-3
  • 原文地址:https://www.cnblogs.com/huey/p/5398553.html
Copyright © 2011-2022 走看看