Is it possible to make the @PathVariable
to return null if the path variable is not in the url? Otherwise I need to make two handlers. One for /simple
and another for /simple/{game}
, but both do the same just if there is no game defined i pick first one from a list however if there is a game param defined then i use it.
@RequestMapping(value = {"/simple", "/simple/{game}"}, method = RequestMethod.GET)
public ModelAndView gameHandler(@PathVariable("example") String example,
HttpServletRequest request) {
And this is what I get when trying to open page /simple
:
Caused by: java.lang.IllegalStateException: Could not find @PathVariable [example] in @RequestMapping
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…