EL表达式

1 定义变量以及运算

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.brilliance.com.cn/interface"
      xsi:schemaLocation="http://www.brilliance.com.cn/interface ../etc/schema/interface.xsd">
    <interface id="demo" version="2.0" type="server" defaultScope="transaction">
        <transaction id="bean" version="2.0">
            <step id="1">
                <filter ref="publicFilter" type="in">
                    <!-- 定义变量,EL表达式支持加减乘除运算-->
                    <field tag="a" value="${1+2}"/>
                    <log value="${a}"/>
                    <!--给变量重新赋值-->
                    <field tag="a" value="${a+2}"/>
                    <log value="${a}"/>
                </filter>
            </step>
        </transaction>
    </interface>
</root>

输出结果:

image-20221027141853880

2 调用公共静态函数

调用方式:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.brilliance.com.cn/interface"
      xsi:schemaLocation="http://www.brilliance.com.cn/interface ../etc/schema/interface.xsd">
    <interface id="demo" version="2.0" type="server" defaultScope="transaction">
        <transaction id="bean" version="2.0">
            <step id="1">
                <filter ref="publicFilter" type="in">
                    <!--调用静态函数-->
                    <field tag="a" value="${substr(cat('a','bc'),1,3)}"/>
                    <field tag="a" value="${formatNow('yyyyMMdd')}"/>
                </filter>
            </step>
        </transaction>
    </interface>
</root>

输出结果:

image-20221027142038454

3 公共非静态函数调用

调用方式:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.brilliance.com.cn/interface"
      xsi:schemaLocation="http://www.brilliance.com.cn/interface ../etc/schema/interface.xsd">
    <interface id="demo" version="2.0" type="server" defaultScope="transaction">
        <transaction id="bean" version="2.0">
            <step id="1">
                <filter ref="publicFilter" type="in">
                    <!--调用公共非静态函数-->
                   <field tag="len" value="${__this.getLen('测试abc')}"/>
                </filter>
            </step>
        </transaction>
    </interface>
</root>

输出结果:

image-20221027142134129

results matching ""

    No results matching ""