Spring笔记 - Spring Expression Language (SpEL表达式)
来源:互联网 发布:软件实施方案 编辑:程序博客网 时间:2024/06/13 05:04
基本表达式
数字5 <property name="count" value="#{5}"/>
联合方式 <property name="message" value="The value is #{5}"/>
浮点型 <property name="frequency" value="#{89.7}"/>
科学表达式10000.0 <property name="capacity" value="#{1e4}"/>
String <property name="name" value="#{'Chuck'}"/> <property name='name' value='#{"Chuck"}'/>
Boolean <property name="enabled" value="#{false}"/>
引用Bean <property name="instrument" value="#{saxophone}"/> 等价 <property name="instrument" ref="saxophone"/>
引用Bean属性 <property name="song" value="#{kenny.song}"/>
引用Bean方法 <property name="song" value="#{songSelector.selectSong()}"/>
进阶一 <property name="song" value="#{songSelector.selectSong().toUpperCase()}"/>
进阶二 防空指针 <property name="song" value="#{songSelector.selectSong()?.toUpperCase()}"/> 防空指针
使用静态类 T(java.lang.Math)
使用静态属性 <property name="multiplier" value="#{T(java.lang.Math).PI}"/>
使用静态方法 <property name="randomNumber" value="#{T(java.lang.Math).random()}"/>
运算表达式
+ <property name="adjustedAmount" value="#{counter.total+42}"/>
- <property name="adjustedAmount" value="#{counter.total-20}"/>
* <property name="circumference" value="#{2 *T(java.lang.Math).PI*circle.radius}"/>
/ <property name="average" value="#{counter.total/counter.count}"/>
% <property name="remainder" value="#{counter.total%counter.count}"/>
^ <property name="area" value="#{T(java.lang.Math).PI*circle.radius^2}"/>
+ overloaded <property name="fullName value="#{performer.firstName + ' ' + performer.lastName}"/>
== eq equal <property name="equal" value="#{counter.total==100}"/>
<= <propertyname="hasCapacity"value="#{counter.total le 100000}"/>
Equal == eq
Less than < lt
Less than or equals <= le
Greater than > gt
Greater than or equals >= ge
逻辑表达式
and A logical AND operation; both sides must evaluate true for the expression to be true
or A logical OR operation; either side must evaluate true for the expression to be true
not or ! A logical NOT operation; negates the target of the operation
<property name="largeCircle" value="#{shape.kind =='circle'andshape.perimeter gt 10000}"/>
<property name="outOfStock" value="#{!product.available}"/>
条件表达式 ?: <property name="instrument" value="#{songSelector.selectSong()=='JingleBells'?piano:saxophone}"/>
<propertyname="song" value="#{kenny.song !=null?kenny.song:'Greensleeves'}"/>
等价 Elvis operator <propertyname="song"value="#{kenny.song?:'Greensleeves'}"/>
正则表达式 <property name="validEmail"value= "#{admin.email matches '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.com'}"/>
集合处理
<util:listid="cities">
<bean class="com.habuma.spel.cities.City"
p:name="Chicago"p:state="IL"p:population="2853114"/>
<bean class="com.habuma.spel.cities.City"
p:name="LasCruces"p:state="NM"p:population="91865"/>
</util:list>
List <property name="chosenCity" value="#{cities[2]}"/>
进阶 <property name="chosenCity" value="#{cities[T(java.lang.Math).random()*cities.size()]}"/>
Map <property name="chosenCity" value="#{cities['Dallas']}"/>
Properties <util:properties id="settings" location="classpath:settings.properties"/>
Properties <property name="accessToken" value="#{settings['twitter.accessToken']}"/>
systemEnvironment <property name="homePath" value="#{systemEnvironment['HOME']}"/>
systemProperties <property name="homePath" value="#{systemProperties['application.home']}"/>
String s 'This is a test'[3]
.?[] 条件选择成员 <property name="bigCities" value="#{cities.?[population gt 100000]}"/>
.^[] and .$[], for 第一个和最后一个匹配成员 <property name="aBigCity" value="#{cities.^[population gt 100000]}"/>
.![] 抽取集合 List <property name="cityNames" value="#{cities.![name]}"/>
进阶 <property name="cityNames" value="#{cities.![name+' , '+state]}"/>
进阶 <property name="cityNames" value="#{cities.?[population gt 100000].![name+' ,'+state]}"/>
- Spring笔记 - Spring Expression Language (SpEL表达式)
- Spring Expression Language (SpEL)-Spring表达式语言
- Spring-SpEL表达式语言 Spring Expression Language
- Spring Expression Language (SpEL)
- SpEL(Spring Expression Language)表达式语言
- Spring 表达式语言 (Spring Expression Language) SpEL
- Spring 表达式语言 (Spring Expression Language) SpEL
- Spring表达式语言(Spring Expression Language,SpEL)
- Spring 表达式语言 (Spring Expression Language) SpEL
- Spring 表达式语言 (Spring Expression Language) SpEL
- Spring in Action 3 -Spring Expression Language (SpEL)
- spring SpEL表达式学习笔记
- Spring学习笔记----SpEL表达式
- Spring学习笔记----SpEL表达式
- Spring学习笔记----SpEL表达式
- Spring表达式语言(Spring Expression Language)
- Spring表达式基础(Spring Expression Language)
- Spring表达式基础(Spring Expression Language)
- 页面设计经典原则
- (LKD3读书记录)Chap5:系统调用
- sql批量加数据
- IOS CoreText.framework --4---- 图文混排
- asp.net 中将汉字转换成拼音
- Spring笔记 - Spring Expression Language (SpEL表达式)
- C/C++中算法运行时间的三种计算方式
- Exception loading sessions from persistent storage java.io.EOFException
- smarty,key从1开始
- jQuery的deferred对象详解
- 从头到尾彻底解析Hash表算法
- 如何很快定位到EXC_BAD_ACCESS错误
- 50个win8使用技巧大全
- 关于Driver Studio 3.2 的安装详解