aspose file tools*
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
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: 1649
    
    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]
 
 
subject: how to pass values to Controller from View?