Announcement Announcement Module
No announcement yet.
Storing Object in session when validation error happens Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Storing Object in session when validation error happens

    hello guys,

    I started working on spring 2-3 months back so i am new for spring. Following is the issue I am facing in my spring MVC application -

    When i submit page, i store Command object(i.e. form) in session in controller. I have overwritten onSubmit(HttpServletRequest request,HttpServletResponse response, Object command, BindException errors) method and store command object in session in this method. So when saves/submits form, after completing database save operation user can see changes he made in GUI.

    I am also using Spring validation framework for some application validation. So if any error is occured in validator class it directly goes to Spring framework so I am not able to store Command object in session and user loses changes his GUI changes.

    Is there any way i can store command object in session when validation error happens ?

  • #2
    That is normally the default behavior, if that isn't happening something is wrong with your setup.


    • #3
      Thanks Marten for reply !!!

      So do you mean Spring by default store command object in session ?

      If yes, Where we need to specify so that spring will store command object in session. This is my config file for controller.

      <?xml version="1.0" encoding="UTF-8"?>
      <bean id="efxFormController"
      class=" Controller"
      <property name="commandName">
      <property name="commandClass">
      <value> d
      <property name="validator">
      <bean class=" ator" />
      <property name="formView">
      <property name="successView">


      • #4
        Please use [ code][/code ] tags when posting code.

        It is not the default to store an object in the session it is the default to retain the user entered values and validation errors. That should happen out of the box. Also why would you need to store the object in the session, the object would be still available or store it in the model, I wouldn't store it in the session.