シナリオで例外をスローしています。によって処理され@ExceptionHandler
ます。しかし、例外をスローすると、Request method 'POST' not supported
Controller codeと表示されます
@RequestMapping(value = "abcd", method = {RequestMethod.POST,RequestMethod.GET })
public String testAbc(Model model, HttpServletRequest request) throws Exception {
//some piece of code
if(someCondition)
throw new Exception("No data found with id ");
}
ExceptionController クラスのコード
@ExceptionHandler(Exception.class)
public ModelAndView handleException(Exception ex, HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("errorMessage", ex.getMessage());
modelAndView.addObject("errorDetails", ExceptionUtils.getStackTrace(ex));
modelAndView.setViewName("forward:errorPage");
return modelAndView;
}
私が何を間違っているのか分かりません。