简体   繁体   中英

Meaning of Path expression

Can you tell how does the following path expression resolve?. I am having it on top of a REST api.

@Path("{a:forgotpwd|forgot/pwd/apitoken}")

Where Path is javax.ws.rs.Path

See https://docs.oracle.com/cd/E19798-01/821-1841/6nmq2cp26/index.html

a is the name of a path parameter, and forgotpwd|forgot/pwd/apitoken is the regex its value must match.

So:

@Path("{a:forgotpwd|forgot/pwd/apitoken}")
@GET
Response foo(@PathParam("a") a) {
  if (a.equals("forgotpwd") {
     ...
  } else {
     ...
  }
}

will match the URLs forgotpwd or forgot/pwd/apitoken (with whatever leading component is configured of course). Other paths will return 404.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM