• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How to get data from a HTML form in Spring MVC Controller?

 
Ranch Hand
Posts: 42
Firefox Browser Tomcat Server Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 42152
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Jeanne Boyarsky
author & internet detective
Posts: 42152
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anupam Dee wrote: am not able to understand the @ModelAttribute annotation also..


Missed this on first read. This thread explains it well.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is another good tutorial to get you started.

http://krams915.blogspot.com/2010/12/spring-3-mvc-using-modelattribute-in.html
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 42
Firefox Browser Tomcat Server Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic