This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Spring and the fly likes how to pass values to Controller from View? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "how to pass values to Controller from View?" Watch "how to pass values to Controller from View?" New topic
Author

how to pass values to Controller from View?

Raghu Sha
Ranch Hand

Joined: Feb 02, 2013
Posts: 122
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

Joined: Oct 31, 2011
Posts: 498

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).


PM Me If You Want to get Urgent Help on Java Programming
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

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


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to pass values to Controller from View?
 
Similar Threads
JSP page Body color not coming green despite specifying in CSS.
Encrypt form POST data before calling servlet through JSP
JSP <a href> tags breaks page functionality
Retrieve records from MySQL using radio button
Very strange behaviour with form based login and css file