一般情况下,Java的属性变量名都以小写字母起头.但也存在特殊情况,需要大写字母开头.
JavaBean允许大写字母起头的属性变量名,不过必须满足"变量的前两个字母要么全部大写,要么全部小写"的要求.
如: brand, IDCode, IC, ICCard等,这些变量名都是合法的.
而iC, iCCard, iDCode等属性名则是非法的.
<bean id='foo' class="com.test.Foo">
<property name="iDCode" value="01010"/>
</bean>
Java 语言本身在不会报错,但Spring容器时将得到失败的结果:
Error setting property values; nested exception is org.springframework.
beans.NotWritablePropertyException:Invalid property 'iDCode' of bean class[....]:
Bean property 'iDCode' is not writable or has an invalid Setter method. Did you mena 'IDCode'?
Caused by: org.springframework.beans.NotWritablePropertyException:Invalid property 'iDCode' of bean class