Results 1 to 2 of 2

Thread: ModelAttribute on exception handlers

  1. #1

    Exclamation ModelAttribute on exception handlers

    I am new to spring MVC. So, sorry if I am saying something that does not make any sense.
    I would like to get the modelAttribute(my form object) in my exceptions handlers, is that possible?
    So, I could be able to send the previous form data to the JSP that is handling the exception.

    I read the spring MVC exception handler documentation, and it seemed not possible.
    So what you masters of Spring can tell me ?
    Is there any easy and not so forced way to do that?

    Spring framework is normally flexible and extensible. But the exception handler life cycle in Spring MVC has being a little bit hard to work with, at least for me .
    Last edited by rafaelweingartner; Jun 6th, 2012 at 09:28 PM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Well it depends... If you use an annotated method as an exception handler then you can (@ExceptionHandler) but if you use the HandlerExceptionResolver interface you cannot. The exception handling mechanism is broader then just controllers and as such it has to cover the common cases and not every handler knows or has a model and as such that isn't available, next to that the error could occur even before the model would be constructed or would be there.

    However it doesn't mean the data isn't there, it still is http and as such everything is available as either request parameters or in the session (if you use @SessionAttributes).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •