Annotation Interface QueryParam


@Documented @Retention(SOURCE) @Target(PARAMETER) public @interface QueryParam

Binds the value of a HTTP query parameter to a web route method parameter whose name indicates the name of the parameter.

The annotated parameter can be of any type as long as it can be decoded by the parameter converter injected in the web server module.

A query parameter can be defined as optional when the method parameter is an Optional, it is otherwise considered as required and a MissingRequiredParameterException will be thrown if the route is invoked with the parameter missing.

If the request contains multiple query parameters with the same name, the first one is bound unless the method parameter is an array, a Collection, a List or a Set in which case all values are bound. The parameter converter may also split raw values around a value separator (eg. value 1,2,3,4 can be bound to a list of integers).


 @WebRoute( ... )
 public void handler(@QueryParam int requiredParameter) {
     ...
 }

 @WebRoute( ... )
 public void handler(@QueryParam Optional<Integer> optionalParameter) {
     ...
 }

 @WebRoute( ... )
 public void handler(@QueryParam List<Integer> multiValueParameter) {
     ...
 }
 
Since:
1.0
Author:
Jeremy Kuhn
See Also: