Logging exceptions with spring web flow -
Hi,
I'm a newbie with Spring Web Flow I'm trying to figure out The easiest way to log exception is within a flow file. There is a tag called Exception Handling on Controlling Base Global Exception Handling Using A controller's advice allows you to use the same exception handling techniques, but does not apply them to the whole application, not just for a different controller. You supported three types of annotations can think of them powered interceptor as annotated with any class Please more info for. Exception Handler but I can not find any documents about logging exceptions. I know that third-party libraries exception (
spring ,
hibernating ) are logged in, but I want to handle the exception and I want to make my own log entries I am
@ExceptionHandler
@Controller public square ExceptionHandlingController {@ExceptionHandler (Exception.class) public ModelAndView getExceptionPage (exception e, HttpServletRequest request) {// catch all exceptions / / here If anything, with the exception object (IsAjax (request)) {// exception that comes to Ajax requests ModelAndView model = new ModelAndView ( "forward: / app / webExceptionHandler / ajaxErrorRedirectPage"); Model.addObject ("exception", exception); Model.addObject ("url", req.getRequestURL ()); Model.setViewName ("Error"); Return model; } Else {// If there is an exception for all non-ajax request model and visual model = New ModelAndView ("forward: / app / webExceptionHandler / nonAjaxErrorRedirectPage"); Model.addObject ("exception", exception); Model.addObject ("url", req.getRequestURL ()); Model.setViewName ("Error"); Return model; }} @ExceptionHandler ({SQLException.class, DataAccessException.class}) public String databaseError () {// specific exception SQLException return "databaseError" catches; } Private Stable Boolean is AJAX (HTPSArlet Request) {Return "XMLHttpRequest" .equals (request.getHeader ("X-requested-with")); }}
@ControllerAdvice Class
@ControllerAdvice becomes a controller-advised and method :.
@ControllerAdvice class GlobalControllerExceptionHandler {@ExceptionHandler (DataIntegrityViolationException.class) public void handleConflict () nothing {//}}
Comments
Post a Comment