今天说两个注解。

关于@PathParam 和 @QueryParam,两个注解都是取路径的,但是方式不同。这里我之前也遇到问题了。主要是看你怎么传入的路径。

关于@QueryParam用法,我们直接取参数传入的名字。

如  localhost:8080/xxxx?bood=123456.此时我们就用QueryParam  

@GET
@Path("/introduction")
Response introduction(
        @QueryParam("bookId") Integer bookId,
        @QueryParam("gg") Integer gg,
        @QueryParam("version") String version,
        @QueryParam("platform") String platform,
        @QueryParam("vps") String vps
);

如果路径 localhost:8080/xxxx/123456我们就把路径改一下就可以了。 

@GET
@Path("/introduction/{bookId}")
Response introduction(
        @PathParam ("bookId") Integer bookId,
        @PathParam ("gg") Integer gg,
        @PathParam ("version") String version,
        @PathParam ("platform") String platform,
        @PathParam ("vps") String vps
);
最后附上简单常用的注解,和一个讲restful 框架的一个帖子

https://www.zhihu.com/question/28557115

RESTful 两个注解@PathParam 和 @QueryParam


好了,大家,明白了吗

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
猜你喜欢
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2022-02-26
  • 2022-12-23
  • 2021-11-02
相关资源
相似解决方案