spring 学习笔记-----PropertyEditors

[b]基本类型[/b]:是指Spring默认提供的7中属性编辑器的类型,而非Java语言的基本数据类型。他们分别对应了Java语言中7种数据类型。如果是以下7种默认类型,则不需要显式配置对应的PropertyEditor,因为Spring会自动进行处理。否则要自定义相应的PropertyEditor。
[b]1.ByteArrayPropertyEditor[/b]
对应类型:byte[]
配置举例:其中bytes是某个bean中的byte[]类型的属性
<property name="bytes">
<value>hello world!</value>
</property>
说明:Spring会把String类型的hello world!字符串转换为byte[]。
[b] 2.ClassEditor[/b]对应类型:Class
配置举例:其中class是某个bean中的Class类型的属性
<property name="class">
<value>java.lang.String</value>
</property>
说明:Spring会把String类型的java.lang.String字符串转换为类对象Class类的实例。
[b] 3.FileEditor[/b]对应类型:java.io.File
配置举例:其中file是某个bean中的java.io.File类型的属性
<property name="file">
<value>d:/temp/test.txt</value>
</property>
说明:Spring会把String类型的d:/temp/test.txt字符串转换为类对象java.io.File实例。
[b]4.LocaleEditor[/b]对应类型:java.util.Locale
配置举例:其中locale是某个bean中的java.util.Locale类型的属性
<property name="locale">
<value>en-GB</value>
</property>

说明:Spring会把String类型的en-GB字符串转换为Locale类型实例。
[b]5.PropertiesEditor[/b]对应类型:java.util.Properties
配置举例:其中 是某个bean中的java.util.Properties类型的属性
<property name="properties">
<value>
name=foo
age=19
</value>
</property>
说明:Spring会把String类型的name=foo和age=19字符串转换为java.util.Properties实例中的值。
[b]6.StringArrayPropertyEditor[/b]
对应类型:String[]
配置举例:其中strings是某个bean中的String[]类型的属性
<property name="strings">
<value>Bob,Rod,John,Roly</value>
</property>
说明:Spring会把String类型的Bob,Rod,John,Roly字符串转换为String[]实例。
[b]7.URLEditor[/b]对应类型:java.net.URL
配置举例:其中url是某个bean中的java.net.URL类型的属性
<property name="url">
<value>http://www.sina.com</value>
</property>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值