博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Array properties in Spring Framework
阅读量:5900 次
发布时间:2019-06-19

本文共 1417 字,大约阅读时间需要 4 分钟。

Array properties in Spring Framework
Easy, simple, and apperently beyond me
Things are so easy and intuitive with Spring that it can be frustrating when you can't figure out how to do something. I recently had a senior moment when I needed to set a String array property. I looked in several books and did a few online searches and could not find an example. I knew it was going to be easy, I just couldn't believe how easy.
Spring automatically converts the strings in the configuration file into the Java objects required by your application. The mecanism that accomplishes this is a set of beans known as Property Editors. While it is possible to create and configure your own Property Editors, Spring comes preconfigured with Property Editors for most situations.
What makes Spring easy to use is the support for complex types as well as primitives. List, Set, Properties, and Map objects can be ceated with Spring tags. Even better, Spring will convert Lists to Java arrays for some types.
So, if you have Java that looks like this:
?
1
2
3
   
void setProperty1(String[] aStringArray){...}
void setProperty2(List<string> aStringList){...}
</string>
You can configure it with XML that looks like this:
?
1
2
3
4
5
6
7
8
9
10
11
12
   
<property name="property1">
    <list>
        <value>one</value>
        <value>two</value>
    </list>
</property>
<property name="property2">
    <list>
        <value>one</value>
        <value>two</value>
    </list>
</property>

转载地址:http://lehsx.baihongyu.com/

你可能感兴趣的文章
python模块--os模块
查看>>
Java 数组在内存中的结构
查看>>
《关爱码农成长计划》第一期报告
查看>>
学习进度表 04
查看>>
谈谈javascript中的prototype与继承
查看>>
时序约束优先级_Vivado工程经验与各种时序约束技巧分享
查看>>
minio 并发数_MinIO 参数解析与限制
查看>>
flash back mysql_mysqlbinlog flashback 使用最佳实践
查看>>
mysql存储引擎模式_MySQL存储引擎
查看>>
python类 del_全面了解Python类的内置方法
查看>>
java jni 原理_使用JNI技术实现Java和C++的交互
查看>>
java 重写system.out_重写System.out.println(String x)方法
查看>>
配置ORACLE 11g绿色版客户端和PLSQL远程连接环境
查看>>
ASP.NET中 DataList(数据列表)的使用前台绑定
查看>>
Linux学习之CentOS(八)--Linux系统的分区概念
查看>>
System.Func<>与System.Action<>
查看>>
asp.net开源CMS推荐
查看>>
csharp skype send message in winform
查看>>
MMORPG 游戏服务器端设计--转载
查看>>
SILK 的 Tilt的意思
查看>>