lundi 23 février 2015

Matching anything in Spring RequestMapping

On Spring MVC rest service I am having issues trying to match anything that is beyond my configured RequestMapping value.


So for e.g. I have this:



@RequestMapping(value = "{configKey}/{arguments:.*}", method = RequestMethod.GET)


Which says that match anything that is beyond the second path variable. The problem is that this e.g. works ok with:



get("/test/document")


while this ends up with 404:



get("/test/document/download")


It is weird that Spring can't handle this regex. I actually tried a lot of solutions, but none of them worked.


Previously I had this configuration on JAX-RS:



@Path("/{configKey}/{arguments:.*}")


And everything was good, but now I am migrating and having this issue.


Does anyone know what's going on and how to fix this?


EDIT:


Adding {configKey}/** - doesn't work


Adding {configKey}/{arguments}/** works, but for e.g. if I call:


get("/test/document/download") I get only test as my config key and document as arguments. In the arguments I expect to get all what's beyond the {configKey}. Which can be anything for e.g. it should work in any case:



get("/test/document")
get("/test/document/download")
get("/test/document/download/1")
get("/test/document/download/1/2")
get("/test/whatever/xxx/1/2/etc")


Which was working with config for JAX-RS: @Path("/{configKey}/{arguments:.*}")


Aucun commentaire:

Enregistrer un commentaire