Dec 12th, 2011, 12:07 AM
I want to get the access to request object in validator
I need to use request object to get some information and session details too. in validator in spring without passing it into argument.
any kind of context or something that can give me request object?
any pointers or solution are appritiated
waiting for answers or hint pls
Last edited by vkpardava; Dec 12th, 2011 at 12:45 AM.
Dec 12th, 2011, 05:10 AM
The validate method on your validator class takes an input an object to be validated (typically your form object). One way is to provide a setter on this form object to the HttpRequest. You can obtain reference from the HttpRequest from your controller handler method (see http://static.springsource.org/sprin...ping-arguments)
Dec 12th, 2011, 12:40 PM
I would design your application so that your validators don't depend on HTTP at all. This is not a good coupling. If you need to do this, you're probably doing it wrong.
Dec 12th, 2011, 11:49 PM
I solved it with the help of RequestContextHolder using this I can access request object in any ordinary class.
Jan 23rd, 2012, 02:58 PM
But can we used Validator on a non-MVC environment? like stand alone app.. Any tutorials on this?
Tags for this Thread