user3062513 user3062513 - 1 year ago 76
Java Question

Regarding optional path in JAX-RS

I want to pass an optional parameter in the JAX-RS path.I am using the below path but its not working.


The resource should get invoked for both with userid and without user id parameter in the path.
Can anyone suggest me what needs to be done?


Answer Source

You could take out the / between the two template parameters and insert it into the regex of the userId


Won't make a difference, but the extra wrapping parenthesis are not needed,
i.e. this {userid: (/[a-zA-Z]{2})?} is sufficient

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download