wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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

how to pass values to Controller from View?

Raghu Sha
Ranch Hand

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


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

Joined: Mar 07, 2010
Posts: 1646

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.


[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.
JSP <a href> tags breaks page functionality
Encrypt form POST data before calling servlet through JSP
Retrieve records from MySQL using radio button
Very strange behaviour with form based login and css file