今天说两个注解。
关于@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
好了,大家,明白了吗