我有一个包含java.util.Set的bean,当我试图填充这个集合时,我得到了BeanException: Index property is not an array, list or map。为什么Jodd不支持套装?我的豆子看起来像:
public class ShippingRule {
private Set<String> returnConstraints;
public Set<String> getReturnConstraints() {
return returnConstraints;
}
public void setReturnConstraints(Set<String> returnConstraints) {
this.returnConstraints = returnConstraints;
}
}我用的是:
ShippingRule shippingRule = new ShippingRule();
BeanUtil.setPropertyForced(shippingRule, "returnConstraints[0]", "restrict1");
BeanUtil.setPropertyForced(shippingRule, "returnConstraints[1]", "restrict2");我漏掉了什么吗?请提出建议,谢谢!
发布于 2014-04-06 18:29:37
因为Collections没有键/值或索引行为或get()方法。让我们看看你的例子:
getProperty("returnConstraints")返回一个Set<String>。在这种情况下,Set上的Set是什么?Set根本不能像这样使用:)
您的示例看起来您的属性必须是String[]或List<String>,或者(不太可能)是Map<Integer, String>。
https://stackoverflow.com/questions/22889466
复制相似问题