I would like to use the @RequestParam annotation like so:
@RequestMapping
public void handleRequest( @RequestParam("page") int page ) {
...
}
However, I want to show page 1 if the user fiddles with the URL parameters and tries to go to page "abz" or something non-numerical. Right now, the best I can get Spring to do is return a 500. Is there a way to override this behavior cleanly without having to take in the parameter as a String?
I looked at the @ExceptionHandler annotation, but it doesn't seem to do anything when I set I use @ExceptionHandler(TypeMismatchException.class)
. Not sure why not.
Suggestions?
P.S. Bonus question: Spring MVC is called Spring MVC. Is Spring MVC with annotations just called Spring @MVC? Google treats them as the same name, which is annoying.