Updated on 2022-02-22 GMT+08:00

Basic Operators

EL supports most of the arithmetic and logic operators provided by Java.

Operator List

Table 1 Basic operators

Operator

Description

.

Accesses a Bean property or a mapping entry.

[]

Accesses an array or linked list.

()

Organizes a subexpression to change priority.

+

Plus sign

-

Minus or negative sign

*

Multiplication sign

/ or div

Division sign

% or mod

Modulo

== or eq

Test whether equal to.

!= or ne

Test whether unequal to.

< or lt

Test whether less than.

> or gt

Test whether greater than.

<= or le

Check whether less than or equal to.

>= or ge

Test whether greater than or equal to.

&& or and

Test logic and.

|| or or

Test logic or.

! or not

Test negation.

empty

Test whether empty.

?:

The expression is similar to if else. If the statement in front of ? is true, the value of the expression between ? and : is returned. Otherwise, the value following : is returned.

Example

If variable a is empty, default is returned. If variable a is not empty, a itself is returned. The expression is as follows:

#{empty a?"default":a}