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.
You can't use curly brackets inside variable when using regex in Path annotation. Use instead:
@Path("/apps/{itemId: \\d+}")
regex = *( nonbrace / "{" *nonbrace "}" ) ; where nonbrace is any char other than "{" and "}"
Theoretically you can check 10 digits as you want using multiple [0-9]
:
@Path("/apps/{itemId: [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]}")