如本Oracle文档所述:
在
@PathParam和其他基于参数的注解,@MatrixParam,@HeaderParam,@cookieParam,@FormParam遵守同样的规则@QueryParam。@MatrixParam从URL路径段中提取信息。@HeaderParam从HTTP标头中提取信息。@cookieParam从与cookie相关的HTTP标头中声明的cookie中提取信息。
示例(从 此处绘制):
@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模式和结果:
- URI模式: “ / books / 2012 /”
名为getBooks,年份:2012,作者:null,国家/地区:null
- URI模式: “ / books / 2012; author = andih”
getBooks被称为,年份:2012,作者:andih,国家/地区:空
- URI模式: “ / books / 2012; author = andih; country = germany”
getBooks被称为,年份:2012,作者:andih,国家:德国
- URI模式: “ / books / 2012; country =德国; author = andih”
getBooks被称为,年份:2012,作者:andih,国家:德国
对于差异的解释,您可以看一下 URL矩阵参数与请求参数



