jax-rs

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 代表 没有大括号

原文地址:https://www.cnblogs.com/zno2/p/5550412.html