首页 > 编程知识 正文

el表达式判断是否为空,oring是什么意思

时间:2023-05-04 20:15:53 阅读:163660 作者:1366

SpEL 1.Spring表达式语言(SpEL ) :是一种强大的表达式语言,支持运行时查询和目标图。 2 .语法类似于El。 SpEL使用#{.}作为分隔符。 大括号中的所有字符都被认为便于SpEL3.SpEL动态地为bean属性赋值。 在SpEL中,可以使用-bean引用bean调用方法和计算引用对象中属性表达式的值-实现正则表达式的匹配

应用实例car.javapackagecom.lanou 3g.beans.spel; public class car { privatestring brand; private double price; private double tyrePerimeter; publicstringgetbrand ((return brand; } publicvoidsetbrand (string brand ) {this.brand=brand; }public double getPrice () {return price; } publicvoidsetprice (double price ) {this.price=price; }public double getTyrePerimeter () {return tyrePerimeter; } publicvoidsettyreperimeter (doubletyreperimeter ) this.tyre perimeter=tyre perimeter; }@Overridepublic String toString () {return 'Car [brand=' brand ',price=' price ',tyre perimeter=' tyre perimeter 公共类地址{ privatestring city; 私有字符串; 公共字符串获取站点() {return city; }publicvoidsetcity(stringcity ) {this.city=city; }public String getStreet () {return street; } publicvoidsetstreet (string street ) {this.street=street; }@Overridepublic String toString () {return 'Address [city=' city ',street=' street '] ' ); } person.javapackagecom.lanou 3g.beans.spel; public class person { privatestring name; 私有卡; 私有字符串; 私有字符串信息; 公共字符串获取名称() {return name; }publicvoidsetname(stringname ) {this.name=name; }公共获取卡() {return car; }publicvoidsetcar(carcar ) {this.car=car; }公共字符串获取站点() {return city; }publicvoidsetcity(stringcity ) {this.city=city; }public String getInfo () {return info; }publicvoidsetinfo(stringinfo ) {this.info=info; } @ overridepublicstringtostring ((return ' person ) name='name ),car=' car ',city=' city ',info=' info '] ' ' ' XML version=' 1.0 ' encoding=' utf-8 '? beans xmlns=' http://www.spring framework.org/schema/beans ' xmlns 3360 xsi=' http://www.w3.org/2001/XML schema-instance ' xsi : schema location=' http://www.spring framework.org/schema/bean s 3358 www.spring framework spring-beans.xsd ' bean id=' address ' class=' com.lanou 3g.beans.spel.address ' pad eet ' value=' Nanjing Lu '/property/bean bean id=' car ' class=' com.lanou 3g.beans.speans property property name=' name - spel--使用property name=' tyre perimeter ' value=' # { t (Java.lang.math ).pi*2}'/property/beanbeanid=' 在SpEL中应用另一个bean-- property name=' car ' value=' # { car } '/property! 在SpEL中使用运算符--property name=' info ' value=' # { car.price 300000?' 金' : '银' } '/property/bean/beans test.javapackagecom.lanou 3g.beans.spel; importorg.spring framework.context.application context; importorg.spring framework.context.support.classpathxmlapplicationcontext; 公共类测试(publicstaticvoidmain (string [ ] args ) applicationcontextctx=newclasspathxmlapplicationcontext ) ) beast system.out.println(address; carcar=(car ) CTX.getbean('car ); system.out.println(car; 人员=(人员) CTX.getbean ) )人员); system.out.println(Person ); }运行结果Address [city=BeiJing,street=Nanjing Lu ] car [ brand=aodi,price=300000.0,tyre perimeter=6.28318530717958888880

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。