Spring Expression Language

載入IP參數, 轉成List

ip.list=192.168.56.101,192.168.56.102

@Value("#{'${ip.list}'==''?null:'${ip.list}'.split(',')}") 空參數值→轉成Null
or
@Value("#{'${ip.list}'==''?T(java.util.Collections).emptyList():'${ip.list}'.split(',')}") 空參數值→轉成Empty List
private List<String> ipList;

Reference

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s