文章字数:83,阅读全文大约需要1分钟
使用copyProperties()复制时Boolean类型的一直无法复制,最后看到了一些信息
- 在网上找到分析源码513行只支持booleanBoolea类型的getXxx()可以使用,如果方法是isXxx()就只有boolean可以
1
2
3
4
5
6
7
8
9if (argCount == 0) {
if (name.startsWith(GET_PREFIX)) {
// Simple getter
pd = new PropertyDescriptor(this.beanClass, name.substring(3), method, null);
} else if (resultType == boolean.class && name.startsWith(IS_PREFIX)) {
// Boolean getter
pd = new PropertyDescriptor(this.beanClass, name.substring(2), method, null);
}
}
属性名不要用isXXX命名了