[英]Jodd BeanUtilBean doesn't support java.util.Set?
I've a bean that contains a java.util.Set, when I try to populate the Set, I got BeanException: Index property is not an array, list or map
. 我有一个包含java.util.Set的bean,当我尝试填充Set时,我得到了
BeanException: Index property is not an array, list or map
。 Why Jodd doesn't support Set ? 为什么Jodd不支持Set? My bean look like:
我的豆子看起来像:
public class ShippingRule {
private Set<String> returnConstraints;
public Set<String> getReturnConstraints() {
return returnConstraints;
}
public void setReturnConstraints(Set<String> returnConstraints) {
this.returnConstraints = returnConstraints;
}
}
and I populate the with: 我用填充:
ShippingRule shippingRule = new ShippingRule();
BeanUtil.setPropertyForced(shippingRule, "returnConstraints[0]", "restrict1");
BeanUtil.setPropertyForced(shippingRule, "returnConstraints[1]", "restrict2");
am I missing something ? 我错过了什么吗? Please advise and thanks!
请指教,谢谢!
Because Collection
s do not have key/value or index behavior or get()
method. 因为
Collection
没有键/值或索引行为或get()
方法。 Let's look your example: 让我们看一下您的示例:
getProperty("returnConstraints")
returns a Set<String>
. getProperty("returnConstraints")
返回一个Set<String>
。 In that case, what would be the [0]
on the Set
? 在这种情况下,
Set
上的[0]
是什么? Set
simply can not be used like this :) Set
根本不能这样使用:)
Your example looks like your property has to be String[]
or List<String>
or (unlikely) Map<Integer, String>
. 您的示例看起来您的属性必须是
String[]
或List<String>
或(不太可能) Map<Integer, String>
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.