gpt4 book ai didi

java - 更改 HEAD 请求的 Jersey 默认值

转载 作者:太空宇宙 更新时间:2023-11-04 11:48:35 25 4
gpt4 key购买 nike

默认情况下,Jersey 使用 GET 资源处理 HEAD 请求:

By default the JAX-RS runtime will automatically support the methods HEAD and OPTIONS, if not explicitly implemented. For HEAD the runtime will invoke the implemented GET method (if present) and ignore the response entity (if set).

Chapter 3. JAX-RS Application, Resources and Sub-Resources

是否可以更改此默认值?

最佳答案

无法找到全局更改它的方法,但是,您可以使用 @HEAD 注释实现一个方法,并且将调用该方法而不是 @GET 注释的方法。

@GET
@Path("a/b")
@Produces("application/json")
public Response getSomething() {
.....
}

@HEAD
@Path("a/b")
@Produces("application/json")
public Response headSomething() {
.....
}

当向 a/b 发出 HEAD 请求时,将调用 headSomething 方法。

关于java - 更改 HEAD 请求的 Jersey 默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42067211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com