0

Is there ant way to modify a method like this:

@RequestMapping(value="/{pagina}")
public String pagina(Model model, @PathVariable("pagina") String pagina) {
    return "public/pagina";
}

for allow handle an unknwon number of @PathVariable parameter? I want urls like this:

/<server>/<app>/<path>/.../<path>

be handled this way:

  • the last path variable attribute should be stored in a separated variable;
  • the other path varaiables should be stored in a ArrayList.

anyone knows if this is possible?

1
  • 1
    You'd have to write it yourself with a custom HandlerMethodArgumentResolver. Commented Aug 5, 2014 at 0:52

1 Answer 1

1

Path variables work with specific path variables, in compliance with the URI template spec. You could add a method argument for HttpServletRequest and get the URL from it and then parse out what you want.

If you look at the docs, you might also consider using a matrix variable in your request mapping.

http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-reference/htmlsingle/#mvc-ann-requestmapping

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.