国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

spring學習筆記——SpEL

2019-11-15 01:06:52
字體:
來源:轉載
供稿:網友
sPRing學習筆記——SpEL

1、SpEL非常實用,基本特性:

a.使用Bean的ID來引用Bean

b.調用方法和訪問對象的屬性

c.對值進行算術、關系和邏輯運算

d.正則表達式匹配

e.集合操作

2、案例

<property name = "count" value = "#{5}" />

<property name = "message" value = "the value is #{5}" />

<property name = "capacity" value = "#{1e4}" />

<property name = "name" vaue = "#{'Chuck'}" />//注意單雙引號的使用

<property name = "name" value = '#{"Chuck"}' />

<property name = "enabled" value = "#{false}" />

<property name = "instrument" value = "#{saxophone}" />

<==>

<property name = "instrument" ref= "saxophone" />

<property name = "song" value = "#{kenny.song}" />

<property name = "song" value = "#{kenny.getSong()}" />

<property name = "song" value = "#{kenny.getSong().toUpperCase()}" />

<property name = "song" value="#{kenny.getSong()?.toUpperCase()}"http://防止空指針異常:?.

<property name = "pi" value = "#{T(java.lang.Math).PI}" /> //T運算符會調用類作用域的方法和常量

<property name = "randomNumber" value = "#{T(java.lang.Math).random()}" />

<property name = "adjust" value = "#{counter.total + 42}" /> //加法運算

<property name = "area" value = "#{T(java.lang.Math).PI * circle.radius ^ 2}" /> //乘方運算

<property name = "fullName" value = "#{performer.firstName + ' ' + performer.lastName}" />字符串連接

<property name = "equal" value = "#{counter.total == 100}" />

<property name = "hasCa" value = "#{counter.total le 10000}" /> //== eq,< lt,<= le,> gt,>= ge

<property name = "aaa" value = "#{shape.kind == 'circle' and shapeperimter gt 1000}" /> //and,or,not或!

<property name = "validEmail" value = "#{admin.email matches '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+//.com'}" /> //匹配正則表達式

<property name = "choseCity" value = "#{cities[2]}" />//list集合

<property name = "choeCity" value = "#{cities[T(java.lang.Math).random()*cities.size()]}" />//list集合

<property name = "choseCity" value = "#{cities['Dallas']}" /> //Map集合

<util:properties id = "settings" location = "classpath:settings.properties" />

<property name = "accessToken" value = "#{settings['twitter.accessToken']}" />

<property name = "homePath" value = "#{systemEnvironment['HOME']}" />//systemEnvironment包含了應用程序所在機器上的所有環境變量

<property name = "homePath" value = "#{systemProperties['application.home']}" />//systemProperties包含了Java應用程序啟動時所設置的所有屬性

<property name = "bigCities" value = "#{cities.?[population gt 1000]}" />//.?[]查詢運算符,創建一個新的集合;.^[]和.$[]從集合中查詢出第一個匹配項和最后一個匹配項

<property name = "cityNames" value = "#{cities.![name]}" />//.![]投影運算符:從集合的每一個成員中選擇特定的屬性放入一個新的集合中

<property name = "cityNames" value = "#{cities.![name+' , '+state]}" />

<property name = "cityNames" value = "#{cities.?[population gt 10000].![name + ','+state]}" />


上一篇:反射獲取一個類

下一篇:Hibernate鎖機制

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 繁昌县| 瓮安县| 襄汾县| 科技| 铜鼓县| 南和县| 鄂托克旗| 星子县| 巩留县| 晋州市| 高台县| 福建省| 左贡县| 绥芬河市| 大冶市| 大埔县| 凤翔县| 霸州市| 德兴市| 武冈市| 江北区| 山阴县| 浮山县| 巴彦县| 永济市| 兴海县| 普安县| 德江县| 木兰县| 泸溪县| 赣州市| 中卫市| 建始县| 屯门区| 岫岩| 道孚县| 大化| 铜鼓县| 司法| 特克斯县| 秦安县|