How to pass Hasmap from Html to Spring controller in java.And also I would like to know how to get it from the controller.
Asked
Active
Viewed 82 times
-2
-
what you have tried? – soorapadman Oct 14 '15 at 08:31
-
Post your code/ configuration for people to help you – Bilbo Baggins Oct 14 '15 at 08:37
-
@Soorapadman I just tried to pass it as a normal variable and I could see the map values in the url. but in the controller i couldnt get it. – dona devasia Oct 14 '15 at 08:37
-
http://viralpatel.net/blogs/spring-mvc-hashmap-form-example/ try this :) :) – Bilbo Baggins Oct 14 '15 at 08:38
-
and this too ... http://stackoverflow.com/questions/18280395/passing-a-mapstring-string-to-a-springmvc-controller – Bilbo Baggins Oct 14 '15 at 08:38
1 Answers
0
First of all there is nothing like passing hashmap from html to Spring controller. What you want to accomplish is actually making a http request to web application.
Create a form model which has Map<String,String> as class variable with appropriate setter and getter.
Then in your action;
public @ResponseBody String formPost(@ModelAttribute YourFormClass form, HttpServletRequest request) {
//Rest of your business logic
}
Fatih Donmez
- 4,221
- 2
- 31
- 45