Domanda

I am using Resteasy. If I declare a method and use

@Path(value = "/") or @Path(value = "")

on that method. Is both of them are same? I mean http://localhost:8080/test and http://localhost:8080/test/ will hit same method.

If yes (which is what my finding is). Then how can I identify the requests http://localhost:8080/test and http://localhost:8080/test/ and map them to separate functions, I have separate number of get parameters in both the requests.

È stato utile?

Soluzione

According to the JAX-RS specification (page 17), section 3.7.3 Converting URI Templates to Regular Expressions:

4. If the resulting string ends with '/' then remove the final character.

Therefore, @Path(value = "/") and @Path(value = "") will hit the same method, because the trailing / on the first @Path will be removed.

Accordingly, the requests http://localhost:8080/test and http://localhost:8080/test/ do not differ to one another.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top