On submitting the page, i need to do some process and send some data to the controller. I felt the 'Map' suits for my requirement to pass in the data. Here is what i am doing:
JSP:
<form:hidden id="passMapData" path="passMapData"/>
Controller:
@RequestMapping(value = "/newPage/testData", method = RequestMethod.POST)
public String newPageTestData(@Valid @ModelAttribute("npf") NewPageForm npf, BindingResult result, Model model) {
}
NewPageForm.java:
public class NewPageForm {
private Map<String, String> passMapData = null;
public Map<String, String> getPassMapData() {
return passMapData;
}
public void setPassMapData(Map<String, String> passMapData) {
this.passMapData = passMapData;
}
}
Issue:
On submitting the form, the BindingResult in the controller is showing error "IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.util.Map]"
Cant we pass a Map type to controller in form submit?