vendredi 4 août 2017

Spring global scope optional path variables

i need to create a global scope optional path variable on my website using Spring, so the same controller could handle a requests with URL's like

http://ift.tt/2uarJG0

and

http://ift.tt/2uqiwot

And i managed to do that this way

@RequestMapping("/something")
public class SomethingController {

  @RequestMapping(value = {"", "/{id}) //<-- important line here
  public Model something([...]) {
    return [...]

But let's say that i have 50 controllers in my application and i don't wan't to modify each and every one of them. Is there any simpler way to accomplish what i need? (application-scope or controller class-scope)




Aucun commentaire:

Enregistrer un commentaire