【发布时间】:2012-09-10 09:09:00
【问题描述】:
线程继续sending-data-back-to-controller-spring-mvc
我正在开发一个产品详细信息页面,我需要向用户显示一些选项,用户将选择其中的几个选项,并且在提交按钮上,产品应该被添加到购物篮中。 我的意图是将该数据对象传输到我的购物车控制器,以便我可以使用这些值,并且由于该对象包含动态值,因此无法定义预先确定的字段对象。 这是我的数据对象
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;
// same lazy map initialization
}
在我的产品详细信息页面控制器中,我将值设置为:
model.addAttribute("prsData", productData.getPrsData());
在我的产品详细信息页面 JSP 上,我的表单中有这个:
<form:form method="post" commandName="prsData" action="${addProductToCartAction}" >
<form:hidden path="prsCDData[''${prsCDDataMap.key}'']
[${status.index}].configuredDesignData['${configuredDesignDataMap.key}']
[${configuredDesignDataStatus.index}].code" />
</form:form>
但是当我点击提交按钮时,我得到了以下异常
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]
我不确定我在哪里做错了,因为在产品详细信息页面上,这些隐藏字段被正确绑定并且甚至分配了值,但是当提交表单时我遇到了这个问题。
【问题讨论】:
标签: java spring jsp spring-mvc jstl