How to set all post data in ModelMap in Spring MVC?

You should use a @ModelAttribute in the form handler.

Up vote 0 down vote favorite share g+ share fb share tw.

I have many input fields in a form to post data to server side. And in controller, I want to get all attributes in ModelMap like this: public String save(ModelMap model) { .... } I don't want to use @RequestParam since there are so many fields to be sent. I think the data in a form will be posted and saved in ModelMap automatically, but its not working Could anyone help me?

Thanks. Spring-mvc link|improve this question edited Sep 27 '11 at 10:00kalyan1,212310 asked Sep 27 '11 at 9:34Mavlarn1125 80% accept rate.

You should use a @ModelAttribute in the form handler @RequestMapping(value="/submitform", method = RequestMethod. POST) public String save(@ModelAttribute("mydata") MyData myData) { //do something with //myData. GetField1(); //myData.

GetFiled2(); } and this is how you will send the page to the form @RequestMapping("/fillform") public String loadForm(ModelMap model) { //you could also fill MyData, to do autofill on the html form model. Put("mydata", new MyData()); return "fillform"; //jspview resolver will pick up fillform. Jsp }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions