Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to capture multiple parameters using @RequestParam using spring mvc?

Suppose a hyperlink is clicked and an url is fired with the following parameter list myparam=myValue1&myparam=myValue2&myparam=myValue3 . Now how can I capture all the parameters using @RequestParam in spring mvc?

My requirement is I have to capture all the params and put them in a map.

Please help!

like image 615
Shivayan Mukherjee Avatar asked Mar 14 '14 07:03

Shivayan Mukherjee


1 Answers

@RequestMapping(value = "users/newuser", method = RequestMethod.POST)    public String saveUser(@RequestParam Map<String,String> requestParams) throws Exception{    String userName=requestParams.get("email");    String password=requestParams.get("password");     //perform DB operations     return "profile"; } 

You could use RequestParam in the above mentioned manner.

like image 177
Touchstone Avatar answered Sep 23 '22 14:09

Touchstone