About Question enthuware.ocejws.v6.2.194 :

Moderators: Site Manager, fjwalraven

Post Reply
evefuji
Posts: 21
Joined: Fri Apr 11, 2014 8:57 pm
Contact:

About Question enthuware.ocejws.v6.2.194 :

Post by evefuji »

I not understand this explanation:
@HttpMethod(value="GET") is a valid annotation but it must be declared on a annotation

fjwalraven
Posts: 429
Joined: Tue Jul 24, 2012 2:43 am
Contact:

Re: About Question enthuware.ocejws.v6.2.194 :

Post by fjwalraven »

Hi !

The @HttpMethod annotation is a meta annotation. An annotation that is used on other annotations (to create new annotations). The definition is:

Code: Select all

@Target(value=ANNOTATION_TYPE)
@Retention(value=RUNTIME)
@Documented
public @interface HttpMethod
Associates the name of a HTTP method with an annotation. A Java method annotated with a runtime annotation that is itself annotated with this annotation will be used to handle HTTP requests of the indicated HTTP method. It is an error for a method to be annotated with more than one annotation that is annotated with HttpMethod.
The @GET annotation is defined with the @HttpMethod as follows:

Code: Select all

@Target(value=METHOD)
@Retention(value=RUNTIME)
@HttpMethod(value="GET")
public @interface GET
Note: from the explanation given by the @HttpMethod annotation you can conclude that it is not possible to annotate one method with @GET and @POST annotation at the same time.

Regards,
Frits

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests