`

spring 学习笔记-----PropertyEditors

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

说明:Spring会把String类型的en-GB字符串转换为Locale类型实例。
5.PropertiesEditor对应类型: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实例中的值。
6.StringArrayPropertyEditor
对应类型:String[]
配置举例:其中strings是某个bean中的String[]类型的属性
<property name="strings">
 <value>Bob,Rod,John,Roly</value>
</property>
说明:Spring会把String类型的Bob,Rod,John,Roly字符串转换为String[]实例。
7.URLEditor对应类型:java.net.URL
配置举例:其中url是某个bean中的java.net.URL类型的属性
<property name="url">
 <value>http://www.sina.com</value>
</property>
分享到:
评论

相关推荐

    spring-framework-reference-4.1.2

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

    spring-framework-reference4.1.4

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

    Spring.Boot.Cookbook.1785284150

    and teaches you to create and add custom Servlet Filters, Interceptors, Converters, Formatters, and PropertyEditors to a Spring Boot web application. Next it will cover configuring custom routing ...

    spring3.0帮助文档(包含REST资料)

    ◆增强的绑定功能以及注释驱动的格式化:在标准的PropertyEditors之外增加了Converter以及Formatter SPI。 ◆全面的REST支持:在Spring MVC中天然支持REST,如REST式的请求映射,URI变量提取等。 ◆富Portlet 2.0...

    spring chm文档

    Spring Framework 开发参考手册 Rod Johnson Juergen Hoeller Alef Arendsen Colin Sampaleanu Rob Harrop Thomas Risberg Darren Davison Dmitriy Kopylenko Mark Pollack Thierry Templier Erwin ...

    asm-3.2.3.jar

    org.springframework.beans org.springframework.beans.annotation org.springframework.beans.factory org.springframework.beans....org.springframework.beans.propertyeditors org.springframework.beans.support

    Spring中文帮助文档

    2.6.4. 将Spring 应用程序上下文部署为JCA adapter 2.6.5. 计划任务 2.6.6. 对Java 5 (Tiger) 支持 2.7. 移植到Spring 2.5 2.7.1. 改变 2.8. 更新的样例应用 2.9. 改进的文档 I. 核心技术 3. IoC(控制反转)...

    Spring Boot项目中定制PropertyEditors方法

    在本篇文章里小编给大家分享的是一篇关于Spring Boot定制PropertyEditors的知识点内容,有需要的朋友们可以参考学习下。

    Spring API

    2. Spring 2.0和 2.5的新特性 2.1. 简介 2.2. 控制反转(IoC)容器 2.2.1. 新的bean作用域 2.2.2. 更简单的XML配置 2.2.3. 可扩展的XML编写 2.2.4. Annotation(注解)驱动配置 2.2.5. 在classpath中自动搜索组件...

    Escc.Umbraco.PropertyEditors:Umbraco 7的核心属性编辑器

    Escc.Umbraco.PropertyEditors Umbraco 7的核心属性编辑器。RichTextPropertyEditor 此属性编辑器使用几种方法扩展了内置的RTF编辑器。 自定义Angular控制器运行内置控制器,有效地继承了其默认行为。 Angular指令会...

    32 数据转换总结及常见面试题目解析慕课专栏(1)1

    引入了FormatterSPI,相比PropertyEditors 简单直接。ConversionService 为 Converter SPI 和 Forma

Global site tag (gtag.js) - Google Analytics