Jax-rs @QueryParam Example

The following two tabs change content below.
Prasad Kharkar is a java enthusiast and always keen to explore and learn java technologies. He is SCJP,OCPWCD, OCEJPAD and aspires to be java architect.

Latest posts by Prasad Kharkar (see all)

In previous article we saw how we can pass parameters through path. This article will show Jax-rs @QueryParam example.

 

JAX-RS @QueryParam Example:

We will continue with same project as that explained in jax-rs hello world example. Jax-rs @QueryParam example is different that @PathParam example with minor changes. The url to pass and the annotation.

Consider below java file in jax-rs  @QueryParam Example:

Note that @QueryParam(“name”) implies that it is expecting something after “/sayHello”. Some url should be passed with a parameter “name” in jax-rs @QueryParam(“name”) example.

Deploy the application under jboss and hit below url

http://localhost:8080/JAX-RS_examples/rest/HelloWorld/sayHello?name=prasad

You should see the message as below

I hope the jax-rs @QueryParam example was useful.

 

 

Share Button

Prasad Kharkar

Prasad Kharkar is a java enthusiast and always keen to explore and learn java technologies. He is SCJP,OCPWCD, OCEJPAD and aspires to be java architect.

Leave a Reply

Your email address will not be published. Required fields are marked *