Home / Java Patterns and Pitfalls     frequal.com

Multiple Paths for a JAX-RS (Jersey) Endpoint

Sometimes you want the same endpoint to be server on two separate paths. For example:

Syntax for Multiple Paths

For endpoints apple and banana, declare your JAX-RS endpoint with this @Path annotation:
    @Path("/{a:apple|banana}")
You can also leave one alternative blank, so it is served up under the resource's base URL:
    @Path("/{a:apple|}")

Last modified on 9 Jul 2024 by AO

Copyright © 2024 Andrew Oliver