Page 1 of 1

About Question enthuware.ocejws.v6.2.194 :

Posted: Sat May 24, 2014 3:59 pm
by evefuji
I not understand this explanation:
@HttpMethod(value="GET") is a valid annotation but it must be declared on a annotation

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

Posted: Sun May 25, 2014 1:40 am
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