I would like to use the @RequestParam annotation as follows:
@RequestMapping public void handleRequest( @RequestParam("page") int page ) { ... }
However, I want to show page 1 if the user is messing with the URL parameters and trying to go to the "abz" page or something not numerical. Right now, the best I can do for Spring to do this is to return 500. Is there a way to completely override this behavior without having to accept a parameter as a string?
I looked through the @ExceptionHandler annotation but it doesn't seem to do anything when I set up using @ExceptionHandler(TypeMismatchException.class) . Not sure why not.
Suggestions?
PS Bonus question: Spring MVC is called Spring MVC. Is Spring MVC with annotations called only Spring @MVC? Google sees them as the same name, which is annoying.
spring spring-mvc
Brandon yarbrough
source share