I found a tuto to manage exceptions from this site. So here is my handler :
@Controller
@RequestMapping("/adminrole")
public class AdminRole {
...
@ExceptionHandler({org.hibernate.exception.ConstraintViolationException.class})
public ModelAndView handlePkDeletionException(Exception ex) {
ModelAndView model = new ModelAndView("errorPage");
model.addObject("message", "customised message with data to display in error page");
return model;
}
}
Now I want to pass some data , for example the column name of the primary key causing the exception , to the handler in order to display a customised message in the error page. So how to pass those data to the handler ?