VishalDevgire VishalDevgire - 1 year ago 140
Java Question

How to have a @PATCH annotation for JAX-RS?

JAX-RS has annotations for HTTP verbs such as

) and
) but there is no
annotation. How can I have an annotation for the
HTTP verb?

Something like the following:

public Response someCode() {
// Code to handle the request

Answer Source

I got answer here.

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

public @interface PATCH {

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

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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download