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

本文共 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://pmmya.baihongyu.com/

你可能感兴趣的文章
Ubuntu unity安装Indicator-Multiload
查看>>
解决Eclipse中新建jsp文件ISO8859-1 编码问题
查看>>
7.对象创建型模式-总结
查看>>
1、块:ion-item
查看>>
【论文阅读】Classification of breast cancer histology images using transfer learning
查看>>
移动端处理图片懒加载
查看>>
jQuery.on() 函数详解
查看>>
谈缓存和Redis
查看>>
【转】百度地图api,根据多点注标坐标范围计算地图缩放级别zoom自适应地图
查看>>
用户调研(补)
查看>>
ExtJS之开篇:我来了
查看>>
☆1018
查看>>
oracle 去掉空格
查看>>
6.13心得
查看>>
Runtime类
查看>>
eclipse decompiler
查看>>
记一个搜索网盘资源的网站
查看>>
jdk1.7和jdk1.8的String的getByte方法的差异
查看>>
java父子进程通信
查看>>
Android ADB server didn't ACK * failed to start daemon * 简单有效的解决方案
查看>>