In my application, I have a few RequestMappings that only allow POST. If someone happens to fire a GET request at that particular path, they get a 405 error page fed by the
Working Code:
@ControllerAdvice
public class GlobalExceptionController {
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public ModelAndView handleError405(HttpServletRequest request, Exception e) {
ModelAndView mav = new ModelAndView("/405");
mav.addObject("exception", e);
//mav.addObject("errorcode", "405");
return mav;
}
}
In Jsp page (405.jsp):
HTTP Status 405 - Request Method not Support