Announcement Announcement Module
Collapse
No announcement yet.
I want to get the access to request object in validator Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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

    Regards
    Vishal
    Last edited by vkpardava; Dec 12th, 2011, 01: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 http://static.springsource.org/sprin...ping-arguments)

    Comment


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

      Comment


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

        Comment


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

          Comment

          Working...
          X