spring-spel
1.spel常用功能
使用bean的id引用bean #{beanid} #{beanid.getXXX()}
调用方法和访问对象的属性 #{class.fileld}
算术运算 #{T(java.lang.Math).PI*3}
正则表达式 matches关键字 #{admin.email matches '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.com'}
集合操作
定义安全规则
2.表达式测试
Spel类和接口位于包 org.springframework.expression及其子包中spel.support。
ExpressionParser ep = new SpelExpressionParser();
Expression exp =ep.parseExpression("'hello'.concat('world')");
System.out.println(exp.getValue());
3.?.安全运算符
{beanid.getXXX()?.toUpperCase()} 如果beanid.getXXX()为null ?. 不会调用之后的语句
4..?[]集合过滤
#{cd.songList.?[type eq '流行']} 找出类型为流行的歌
#{cd.songList.^[type eq '流行']} 找出类型为流行的歌第一首歌
#{cd.songList.$[type eq '流行']} 找出类型为流行的歌最后一首歌
#{cd.songList.![name]} 投影运算符 将指定属性投影到一个新的集合