java - Spring MVC - handle exception with @ExceptionHandler doesn't render new view -


I think against a border of the spring - I have a simple matter - I am simulating an exception one Service method:

  @RequestMapping (method = RequestMethod.POST) public string register (@RequestParam ("mail") string mail) {New IllegalStateException throw (); }   

and trying to handle the new request via:

  @RequestMapping (value = "/ exception_location") @ExceptionHandler (IllegalStateException .class) Public String HandleException (IllegalStateException Pre) {Return "exception_view"; }   

My web Xml:

  & lt; Error page & gt; & Lt; Exception Type & gt; Java.lang.IllegalStateException & lt; / Exception type & gt; & Lt; Location & gt; / Exception_location & lt; / Location & gt; & Lt; / Error page & gt;   

What happens is that the operation is triggered, but the exception does not provide the view on the client. Is spring configuration okay or does it require access to web.xm? Am I missing something which handler is not getting? Any feedback is appreciated thanks.

I have found a problem - the way to throw an exception should be with the handler in the same controller. I took both methods in the same controller and everything works fine

Comments