且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何为JAX-RS提供@PATCH注释?

更新时间:2023-11-17 23:53:16

我得到答案在其他地方

一个只需要定义一个自定义补丁注释,这意味着您必须使用以下代码编写 PATCH.java 文件:

One will just have to define a custom Patch annotation, what that means is that you will have to write a PATCH.java file with following code:

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@HttpMethod("PATCH")
public @interface PATCH {
}

导入包含PATCH的包。 java ,然后就像其他HTTP方法注释一样使用它:

Import the package containing PATCH.java and then you can use it like other HTTP method annotations:

@PATCH
@Path("/data/{keyspace}")
@Produces({ "application/json" })
public void patchRow(@PathParam("keyspace") String keyspace, String body) 
throws Exception

我用这个@PATCH将一些JSON发送到我的REST服务。

I used this @PATCH to send some JSON to my REST service.