JAX-RS @MatrixParam example
来源:互联网 发布:手机短信软件 编辑:程序博客网 时间:2024/06/05 20:04
Matrix parameters are a set of “name=value
” in URI path, for example,
/books/2011;author=mkyong
In above URI, the matrix parameter is “author=mkyong
“, separate by a semi colon “;
“.
1. @MatrixParam
example
See a full example of using @MatrixParam
in JAX-RS.
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(); }}
See following URI patterns and result.
1. URI Pattern : “/books/2011/
”
getBooks is called, year : 2011, author : null, country : null
2. URI Pattern : “/books/2011;author=mkyong
”
getBooks is called, year : 2011, author : mkyong, country : null
3. URI Pattern : “/books/2011;author=mkyong;country=malaysia
”
getBooks is called, year : 2011, author : mkyong, country : malaysia
4. URI Pattern : “/books/2011;country=malaysia;author=mkyong
”
getBooks is called, year : 2011, author : mkyong, country : malaysia
0 0
- JAX-RS @MatrixParam example
- JAX-RS之@matrixParam和@PathParam
- JAX-RS @PathParam example
- JAX-RS @QueryParam example
- JAX-RS @FormParam example
- JAX-RS @Path URI matching example
- JAX-RS
- JAX-RS
- JAX-RS
- JAX-RS
- JAX-RS
- JAX-RS
- JAX-RS
- JAX-RS
- JAX-RS
- JAX-RS2:JAX-RS CRUD
- JAX-WS、JAX-RS、JAXB
- JAX-WS与JAX-RS
- U3D学习笔记(9)
- 简化AWS CLI操作的jungle
- Nginx开启Gzip压缩
- Google C++测试框架系列:入门
- POJ 1003 Hangover
- JAX-RS @MatrixParam example
- Android开发之简单的聊天室(客户端与服务器进行通信)
- eclipse调试java程序的九个技巧
- 使用ab对nginx进行压力测试
- Java____序列化private static final long serialVersionUID的作用
- 微信企业号开发:微信考勤2如何计算距离
- C#生成音频文件以及转换成需要的格式
- ruby1.8.7/rails2.3.11--启动报错"undefined method `source_index' for Gem:Module (NoMethodError)"
- Intent应用示例