PDA

View Full Version : Redirect to 403 if formBackingObject should not be retrieved.


jasek
Jun 7th, 2006, 09:19 PM
I have several pages that accept a request parameter eg. http://host.com/product.htm?id=123 where the id represents the object to be retrieved from the database (using SimpleFormController). Currently I have code that determines if the remote user has adequate permissions to access the object, and if successful the formBackingObject is populated. What I would like to do is forward/redirect to either a 403 or custom error page in the event that the user is not permitted to view/retrieve the object.
Is there a way of redirecting from within formBackingObject, or should I use AbstractFormController and handle the redirection via the showForm method?

manifoldronin
Jun 8th, 2006, 11:26 AM
You can throw some specific exception type from the controller. In web.xml, that exception type can be mapped to a specific error url that renders a 403 response or whatever custom error page.

jasek
Jun 8th, 2006, 06:06 PM
http://forum.springframework.org/showthread.php?t=22922