| Author |
How to get data from a HTML form in Spring MVC Controller?
|
Anupam Dee
Ranch Hand
Joined: Oct 18, 2010
Posts: 42
|
|
I am new to Spring MVC.
I am facing a simple problem but unable to understand how to do it.
I have a simple form containing an input field and a submit button. All i have to do is to enter the userid in the field and hit enter.. and the user with that id shows up.
But how to get the request parameters in the Controller class ?
i am not able to understand the @ModelAttribute annotation also..
Why should we use this annotation?
Please help me.
Thanks
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26155
|
|
This example from the Spring tutorial shows using the @RequestParam annotation to map HTML form parameters to the method signature. In this case, "petId" is the name of the field on the HTML form.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26155
|
|
Anupam Dee wrote: am not able to understand the @ModelAttribute annotation also..
Missed this on first read. This thread explains it well.
|
 |
Bill Gorder
Bartender
Joined: Mar 07, 2010
Posts: 1282
|
|
Here is another good tutorial to get you started.
http://krams915.blogspot.com/2010/12/spring-3-mvc-using-modelattribute-in.html
|
[How To Ask Questions][Read before you PM me]
|
 |
Sindhu Kodoor
Ranch Hand
Joined: Sep 03, 2010
Posts: 65
|
|
I have done a POC today by following this one :
http://www.mkyong.com/spring-mvc/spring-mvc-form-handling-annotation-example/
hope it benefits you !
|
 |
Anupam Dee
Ranch Hand
Joined: Oct 18, 2010
Posts: 42
|
|
Thank you everyone.
I still have a lot of confusions. But I ll ask them one by one and get them clear.
Thanks once again
|
 |
 |
|
|
subject: How to get data from a HTML form in Spring MVC Controller?
|
|
|