2

I read a few tutorials about forms and submission in Spring 3 MVC. All these examples store the form backing object in the session the following way:

@SessionAttributes({"command"})

What I would like to do is to create the form object (for example: load it from the database) at the moment of form submission, not storing it in the session to be used at the moment of form submission.

How can I do this?

animuson
  • 53,861
  • 28
  • 137
  • 147
curious1
  • 14,155
  • 37
  • 130
  • 231
  • Can you please provide a link to any of that turorials. It sounds strange that ALL store the form backing object in a SESSION. -- I asked for the link, because I have the feeling that you anderstand anyting wrong. – Ralph Nov 19 '11 at 12:32
  • Have you read the [reference guide](http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/mvc.html#mvc-ann-modelattrib-methods)? – M. Deinum Jan 09 '15 at 14:28

1 Answers1

2

Normally in Spring 3 you have only this line for form binding:

@RequestMapping(value = "/addContact", method = RequestMethod.POST)
public String addContact(@ModelAttribute("contact")
                        Contact contact, BindingResult result) {

(you can even skip the @ModelAttribute("contact") annotation)

There is no session.

May have a look at this tutorial: Spring 3 MVC: Handling Forms in Spring 3.0 MVC

But I already have requested you to post a link to the tutorial you used. -- Maybe we are talking about different things.

Etienne Neveu
  • 12,604
  • 9
  • 36
  • 59
Ralph
  • 118,862
  • 56
  • 287
  • 383