Announcement Announcement Module
No announcement yet.
I want to get the access to request object in validator Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 12:45 AM.

  • #2
    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


    • #3
      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.


      • #4
        I solved it with the help of RequestContextHolder using this I can access request object in any ordinary class.


        • #5
          But can we used Validator on a non-MVC environment? like stand alone app.. Any tutorials on this?