<div dir="ltr" style="text-align: justify;" trbidi="on">In this tutorial we will discuss about Matrix parameters, these are a set of <i><b>&#8220;name=value&#8221;</b></i> in URI path, <br />
for example-<br />
<i><b>/salary/21111;empname=dinesh</b></i></p>
<p> In above URI, the matrix parameter is &#8220;empname=dinesh&#8221;, separate by a semi colon &#8220;;&#8221;.<br />
<b>1. <i>@MatrixParam</i> example</b><br />
See a full example of using<i><b> @MatrixParam</b></i> in JAX-RS.</p>
<pre class="highlight" name="code">import javax.ws.rs.GET;
import javax.ws.rs.MatrixParam;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
 
@Path("/employee")
public class EmployeeController {
 
 @GET
 @Path("{empid}")
 public Response getEmpSalary(@PathParam("empid") String empid,
 @MatrixParam("empname") String empname,
 @MatrixParam("jobtype") String jobtype) {
 
 return Response
 .status(200)
 .entity("getEmpSalary is called, empid : " + empid
 + ", empname : " + empname + ", jobtype : " + jobtype)
 .build();
 
 }
 
}
</pre>
<div align='center' id="ads-id"></div>
<p><b>See following URI patterns and result.</b></p>
<p> 1. URI Pattern : <i><b>http://localhost:8181/sdnext/doj/employee/21212/</b></i><br />
<b><br />
</b> <b>getEmpSalary is called, empid : 21212, empname : null, jobtype : null</b></p>
<p> 2. URI Pattern : “<i><b>http://localhost:8181/sdnext/doj/employee/21212;empname=dinesh</b></i>”</p>
<p> <b>getEmpSalary is called, empid : 21212, empname : dinesh, jobtype : null</b></p>
<p> 3. URI Pattern : <i><b>“http://localhost:8181/sdnext/doj/employee/21212;empname=dinesh;jobtype=Software”</b></i></p>
<p> <b>getEmpSalary is called, empid : 21212, empname : dinesh, jobtype : Software</b></p>
<p> 4. URI Pattern : <i><b>“http://localhost:8181/sdnext/doj/employee/21212;jobtype=Software;empname=dinesh”</b></i><br />
<b><br />
getEmpSalary is called, empid : 21212, empname : dinesh, jobtype : Software</b></p>
<p><b>Download SourceCode</b><br />
<b><a href="https://sites.google.com/a/dineshonjava.com/dineshonjava/dineshonjava/JAX-RS%20%40MatrixParam%20example.zip?attredirects=0&;d=1" target="_blank">JAX-RS @MatrixParam example.zip</a></b></p>
<p>
<i><b>References</b></i><br />
1.<b> <i><a href="http://docs.oracle.com/javaee/6/tutorial/doc/giepu.html" target="_blank">JAVA REST Web Services</a></i></b><br />
2. <i><b><a href="http://en.wikipedia.org/wiki/Web_service" target="_blank">Wikipedia for REST Web Service</a></b></i></p>
<p> ; </p>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/2013/06/jax-rs-queryparam-example.html">Previous </a><;<; ; ; || <a href="https://dineshonjava.com/2013/06/jax-rs-web-service-tutorial.html">Index </a>||  ; >;>;<a href="https://dineshonjava.com/2013/06/jax-rs-formparam-example.html">Next</a> >;>;</b></div>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/jax-rs-queryparam-example/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/jax-rs-formparam-example/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '421'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…