行列パラメータは、URIパスの " name = value "の集合です。たとえば、
…./books/2011;author=mkyong
上記のURIでは、行列パラメータは "** author ** mkyong ** "でセミコロン "** ; ** "で区切られています。 === 1. @ MatrixParamの例 JAX-RSで `@ MatrixParam`を使用した完全な例を参照してください。
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("/books") public class BookService {
@GET @Path("{year}") public Response getBooks(@PathParam("year") String year, @MatrixParam("author") String author, @MatrixParam("country") String country) {
return Response .status(200) .entity("getBooks is called, year : " + year + ", author : " + author + ", country : " + country) .build();
}
}
以下のURIパターンと結果を参照してください。 {空} 1。 URIパターン: "** /books/2011/** "
getBooks is called, year : 2011, author : null, country : null
{空} 2。 URIパターン: "** /books/2011; author = mkyong ** "
getBooks is called, year : 2011, author : mkyong, country : null
{空} 3。 URIパターン: "** /books/2011;著者= mkyong;国=マレーシア** "
getBooks is called, year : 2011, author : mkyong, country : malaysia
{空} 4。 URIパターン:「** /books/2011;国=マレーシア;著者= mkyong ** 」
getBooks is called, year : 2011, author : mkyong, country : malaysia
=== ソースコードをダウンロードする ダウンロードする - リンク://wp-content/uploads/2011/07/JAX-RS-MatrixParam-Example.zip[JAX-RS-MatrixParam-Example.zip](6 KB) === 参考文献 . http://jsr311.java.net/nonav/releases/1.1/javax/ws/rs/MatrixParam.html[JAX-RS MatrixParam JavaDoc] link://tag/jax-rs/[jax-rs]link://タグ/パラメータ/[パラメータ]