Thread continued by sending-data-back-to-controller-spring-mvc
I am working on a product details page where I need to show the user some parameters, and the user will select several of them, and on the product the submit button should be added to the basket. My intentions are to pass this Data object to my basket controller so that I can use these values, and since the object contains dynamic values, it is therefore impossible to define an object of predefined fields. This is my data object.
public class PrsData { private Map<String, List<PrsCDData>> prsCDData; public PrsData(){ this.prsCDData = MapUtils.lazyMap(new HashMap<String, List<PrsCDData>>(), FactoryUtils.instantiateFactory(PrsCDData.class)); } } public class PrsCDData { private Map<String, List<ConfiguredDesignData>> configuredDesignData;
In my product detail page controller, I set the values ββas:
model.addAttribute("prsData", productData.getPrsData());
and on my JSP product details page I have this in my form:
<form:form method="post" commandName="prsData" action="${addProductToCartAction}" > <form:hidden path="prsCDData[''${prsCDDataMap.key}''] [${status.index}].configuredDesignData['${configuredDesignDataMap.key}'] [${configuredDesignDataStatus.index}].code" /> </form:form>
But when I click the submit button, I get the following exception
org.springframework.beans.InvalidPropertyException: Invalid property 'prsCDData['Forced'][0]' of bean class [com.product.data.PrsData]: Property referenced in indexed property path 'prsCDData['Forced'][0]' is neither an array nor a List nor a Set nor a Map; returned value was [ com.product.data.PrsCDData@6164f07e ]
I am not sure where I am doing it wrong, because on the product details page these hidden fields are correctly linked and even have the values ββassigned to them, but when the form is submitted, I have to deal with this problem.
Umesh awasthi
source share