将上下文注入Java Jax-RS POJO

时间:2019-04-19 10:17:56

标签: jersey jax-rs jersey-2.0

这是我的终点

@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
public Response replace(@PathParam("id") String id,  
        @Valid WriteCommand replacePersonCommand) {
      ....
}

这是我的WriteCommand

public class WriteCommand Command {

    @NotNull
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        LOG.info(">>setName()");
        this.name = name;
    }

    @Context HttpHeaders httpHeaders;

    public HttpHeaders getHttpHeaders() {
        return httpHeaders;
    }

    public void setHttpHeaders(HttpHeaders httpHeaders) {
        this.httpHeaders = httpHeaders;
    }
}

但是从不注入httpHeaders吗?有什么原因吗?

谢谢

0 个答案:

没有答案