zoukankan      html  css  js  c++  java
  • Spring初学之Spel初配

    Spel又时候可以方便我们为bean的属性赋值,如下配置文件就是常用的一些使用:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    
        <bean id="address" class="spring.beans.spel.Address">
        <!-- 使用SpEL设置字面值 -->
            <property name="city" value="#{'重庆'}"></property>
            <property name="more" value="梁平"></property>
        </bean>
        
        <bean id="car" class="spring.beans.spel.Car">
            <property name="carName" value="#{'奥迪'}"></property>
            <property name="price" value="#{300000}"></property>
            <!-- 用SpEL引用类中的静态方法 -->
            <property name="tyrePermiter" value="#{T(java.lang.Math).PI*80}"></property>
        </bean>
    
        <bean id="person" class="spring.beans.spel.Person">
        <!-- 使用SpEL设置字面值 -->
            <property name="name" value="#{'Tom'}"></property>
            <!-- 使用 SpEL引用其他bean-->
            <property name="car" value="#{car}"></property>
            <!-- 使用SpEL引用其它bean的属性 -->
            <property name="city" value="#{address.city}"></property>
            <!-- 在SpEl中使用运算符 -->
            <property name="info" value="#{car.price>300000?'金领':'白领'}"></property>
        </bean>
    </beans>
  • 相关阅读:
    va_list va_start va_end va_arg 解决变参问题
    标准输出文件
    Qt QDataTime QString 两个类的使用
    联合开发网站
    iOS LLDB调试器和断点调试
    Wireshark 网络抓包工具Wireshark的使用
    linux 操作系统下c语言编程入门
    iOS 应用崩溃日志分析
    iOS sqlite3数据库解析
    iOS 解析手势识别(Gesture Recognizers)
  • 原文地址:https://www.cnblogs.com/hyyq/p/6701721.html
Copyright © 2011-2022 走看看