JAX-RS Send List using QueryParam Annotation

In this tutorial we are going to see how to send list to RESTful web service via URL using JAX-RS @QueryParam annotation

Ask your questions in Our Forum

To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

Create maven web application project and add Jersey dependency in pom.xml. Find Jersey 2.x maven dependency configuration below. If you are new to maven refer our maven tutorials .

Jersey 2.x dependency in pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <name>RestTutorials Maven Webapp</name>
      <!-- JAX-RS -->
        <!-- Jersey 2.19 -->

QueryParamService .java

package com.ehowtonow.webservice;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;

public class QueryParamService {

 public Response getTutorial(@QueryParam("site") String site,
   @QueryParam("tutorial") List<String> tutorial,
   @QueryParam("rank") int rank) {
  return Response
    .entity("Web Site : " + site + "  Tutorial : " + tutorial.toString()
      + " Rank : " + rank).build();

In above class @QueryParam used to get the value of URL query parameter into Java Class.

Configure Jersey 2.x Servlet dispatcher

 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

	<display-name>Restful Webservice Example</display-name>


Now you can run the service and access the service by calling the following URL


Ask your questions in Our Forum

To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

Posts You may Like

  1. Java 8 Stream has already been operated upon or closed
  2. JAX-RS @PathParm Web service Example
  3. Java Tutorial – Java Introduction
  4. How to compare two file paths using Java
  5. Java 8 Sort Map by Value
  6. How to search a word inside String
  7. RESTful Web Services Introduction
  8. How to Modify XML file using DOM Parser
  9. Java DOM XML Parser
  10. JAX-RS @POST using RESTful web service – Jersey 1.x
  11. How to rotate element of List
  12. How to reverse the String using StringBuffer
  13. JAX-RS @MatrixParam Restful Webservice
  14. Convert Map to JSON using Jackson 1.x
  15. XML SAX Parser Introduction

Be the first to comment

Leave a Reply

Your email address will not be published.