New Tutorials:   NUMPY    TKINTER    KOTLIN    JAVASCRIPT    SASS/SCSS    PL/SQL    Matplotlib    C++ Programs
See the Tutorial List

Path Params in GET Rest Request

In JAX-RS, you can use @PathParam annotation to extract the parameter from the request URI and map it to any method.

Suppose the client wants the information for student with the roll number 1 or 2 and not for all the students. In such situation, we can use the @PathParam to map this to a method which will return only the requested student's record.

public Student getStudentWithRollNo(@PathParam("rollno")int rollNo)
	Student student = studentService.getStudentWithRollNo(rollNo);
	return student;

The @PathParam annotation will map the rollno from the resource URI to the rollNo argument of the method.

Path Params in GET Request

Path Params in GET Request

Thus with the @PathParam annotation we can map the request URI parameters with the Java method arguments.