to. If the target type is not String, Spring automatically converts to the appropriate type. All simple types such as int, long, Date, etc. are supported. You can further customize the conversion process through a WebDataBinder (see the section called “Customizing WebDataBinder initialization”) or by registering Formatters with the FormattingConversionService (see Section 8.6, “Spring Field Formatting”).
8.5 Spring Type Conversion
Spring 3 introduces a core.convert package that provides a general type conversion system. The
system defines an SPI to implement type conversion logic, as well as an API to execute type conversions
at runtime. Within a Spring container, this system can be used as an alternative to PropertyEditors to
convert externalized bean property value strings to required property types. The public API may also be
used anywhere in your application where type conversion is needed.
本文介绍了Spring框架中的类型转换机制,包括如何将请求参数等字符串值转换为目标类型,如方法参数或字段类型。此外还探讨了Spring 3引入的核心转换包,提供了一种通用的类型转换系统,并解释了该系统的SPI实现及运行时执行类型转换的方法。
1074

被折叠的 条评论
为什么被折叠?



