By default in JAX-RS, ALL URLs specified in @Path annotations are CASE-SENSITIVE. In this tutorial, I am giving a simple example of CASE-INSENSITIVE URLs which cane be used inside @Path annotation on any Jersey JAX-RS REST API.
How to make URLs case in-sensitive
To make URLs case-insensitive, change the @Path
URLs like below:
@Path("/{employees}") public class JerseyService { //Code }
Change above declaration to this:
@Path("/{employees : (?i)employees}") public class JerseyService { //Code }
Now above @Path annotation will be able to match any variation of lowercase and UPPERCASE letters in employees
.
Demo Usage
Here, I am modified the sourcecode of my previous example of Jersey RESTful Client Examples.
I sent following requests to HTTP GET /{employees : (?i)employees}
path, and all paths matches correctly.
http://localhost:8080/JerseyDemos/rest/EMPLOYEES

http://localhost:8080/JerseyDemos/rest/EmPlOyEEs

http://localhost:8080/JerseyDemos/rest/employees

Feel free to contact in you find any problem in this example.
Happy Learning !!
Comments