JAX-RS @MatrixParam annotation
http://localhost:8001/…/rest/customers;custNo=100;custName=Satya
Matrix parameters are another way defining the parameters to be added to URL. If you observe the above syntax, client is passing two parameters each are separated by semicolon(;), these parameters are called as matrix parameters. Remember these parameters may appear any where in the path
Steps to Implement this Web Service Application
1.Create Dynamic web project in eclipse, convert that into Maven Project
2.Add RESTEasy jar files manually / through Maven by writing repo details in pom.xml(Skipping)
3.Create RESTFul webservice using Jersey
package services;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
@Path("/students")
public class MatrixParamService{
@GET
@Produces("text/html")
public Response getResultByPassingValue(
@MatrixParam("rollno") String rollno,
@MatrixParam("name") String name,
@MatrixParam("address") String address) {
String output = "<h1>@MatrixParam Example</h1>";
output = output+"<br>Roll No : "+rollno;
output = output+"<br>Name : "+name;
output = output+"<br>Address : "+address;
return Response.status(200).entity(output).build();
}
}
4.Configure web.xml, Register RESTEasy dependency class (Skipping)
5.Test Webservice directly by using URL / writing webservice client
PREVIOUSJAX-RS DefaultValue
NEXTJAX-RS FormParam