一、引用静态方法

(1)在ONGL中引用

1
2
3
4
5
6
7
8
<select id="selectTest">
<if test="@com.test.DateUtils@isLeapYear(year)==true">
select * from tableA
</if>
<if test="@com.test.DateUtils@isLeapYear(year)==false">
select * from tableB
</if>
</select>

(2)在SQL中引用

1
2
3
<select id="selectTest">
select * from tableA where year=${@com.test.DateUtils@getYear()}
</select>

二、引用静态常量

(1)在ONGL中引用

1
2
3
4
5
<select id='selectTest'>
<if test="year==@com.test.Consants@CURRENT_YEAR">
select * from tableA
</if>
</select>

(2)在SQL中引用

1
2
3
<select id="selectTest">
select * from tableA where year=${@com.test.Constants@CURRENT_YEAR}
</select>

三、引用枚举类型

(1)在ONGL中引用

1
2
3
4
5
<select id='selectTest'>
<if test="year==@com.test.Enums@YEAR.getValue()">
select * from tableA
</if>
</select>

(2)在SQL中引用

1
2
3
<select id="selectTest">
select * from tableA where year=${@com.test.Enums@YEAR.getValue()}
</select>

四. 引用内部类

内部类引用使用 $ 符号

1
2
3
4
<select id="selectTest">
select * from tableA
where year=${@com.test.OutClasses$InnerClassEnums@YEAR.getValue()}
</select>