JAX-RS (REST)No Comments

In JAX-RS, you can use @QueryParam annotation to inject URI query parameter into Java method. for example,

In above URI pattern, query parameter is “url=javasail.com“, and you can get the url value with @QueryParam(“url”).

  • @QueryParam example

See a full example of using @QueryParam in JAX-RS.

URI Pattern : “users/query?from=100&to=200&orderBy=age&orderBy=name

Like it ?
@QueryParam will convert the query parameter “orderBy=age&orderBy=name” into java.util.Listautomatically.
  • Programmatic Query Parameter

Alternatively, you can get the query parameters grammatically, via “@Context UriInfo“. See equivalent version below :

URI Pattern : “users/query?from=100&to=200&orderBy=age&orderBy=name

  • @DefaultValue example

@DefaultValue is good for optional parameter.

URI Pattern : “users/query

Be the first to post a comment.

Add a comment

Warning: stream_socket_client(): unable to connect to http://browscap.org/version (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in /home/javasail/public_html/wp-content/plugins/wp-statistics/vendor/browscap/browscap-php/src/phpbrowscap/Browscap.php on line 1366

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/javasail/public_html/wp-content/plugins/wp-statistics/vendor/browscap/browscap-php/src/phpbrowscap/Browscap.php on line 1004