首页 > 其他 > 详细

jax-rs

时间:2016-08-06 09:40:35      阅读:222      评论:0      收藏:0      [点我收藏+]

https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/index.html

http://tools.ietf.org/html/rfc5234

通过java api 注解类生成 RESTful 

举例:@Path("/swagger.{type:json|yaml}")

请求路径必须符合这种格式,且这种格式中的值可以通过type获取

 

@Path("widgets")
 public class WidgetsResource {
  @GET
  String getList() {...}

  @GET @Path("{id}")
  String getWidget(@PathParam("id") String id) {...}
 }

带冒号,值有限制

不带冒号,任意值

 param = "{" *WSP name *WSP [ ":" *WSP regex *WSP ] "}"
 name = (ALPHA / DIGIT / "_")*(ALPHA / DIGIT / "." / "_" / "-" ) ; \w[\w\.-]*
 regex = *( nonbrace / "{" *nonbrace "}" ) ; where nonbrace is any char other than "{" and "}"

 

@Path(param)

WSP 意思是 white-space

* 代表 任意多个

name 代表 (ALPHA ...)

ALPHA 代表 字母

DIGIT 代表 数字

regex 代表 正则表达式

nonbrace 代表 没有大括号

jax-rs

原文:http://www.cnblogs.com/zno2/p/5550412.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!