If I use the "{}" to specify the count condition in the regular expression of JAX-RS @Path
, eclipse throws as error.
@Path("/apps/{itemId:\\d{10}}")
public Response getItems(...
The @Path annotation value
'/apps/{itemId:\d{10}}'
is invalid: missing '{' or '}'.
Is above JAX-RS Path not a valid path ? Is it due to eclipse JAX-RS validator problem ? If I just specify @Path("/apps/{itemId}")
there is no error.
答案 0 :(得分:2)
using regex in Path annotation时,不能在变量内使用大括号。改用:
@Path("/apps/{itemId: \\d+}")
regex = *(nonbrace /“ {” * nonbrace“}”);其中nonbrace是除“ {”和“}”以外的任何字符
理论上,您可以使用多个[0-9]
来检查10位数字:
@Path("/apps/{itemId: [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]}")