• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to pass values to Controller from View?

 
Raghu Sha
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am using Spring MVC 3

how to pass values to Controller from View?

1) on click of hyperlink (Customer) have to pass User Name to cutomerPage (Controller)?
2) On Form sumbit have to pass userName & emailaddress to userPage (Controller)

form1.jsp

 
Nam Ha Minh
Ranch Hand
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's pretty easy in Spring MVC: Just declare a HttpServletRequest argument in the controller method and use the getParameter() method to retrieve parameter value from URL query string (GET) or from HTML form (POST).
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the spring form tag libs to bind your properties to an object. Spring will then take your form fields and turn that into the object you are expecting. If you are just trying to get parameters you can use the @RequestParam annotation. I suggest you have a look at this entire section of the ref docs for more information.

http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-ann-methods
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic