Category: java
Spel methods properties and object navigation
Published on 30 Sep 2026
Explanation
SpEL can access properties of Java objects using dot notation.
Code:
#{user.name}
#{user.email}
#{user.address.city}
Explanation
SpEL can invoke methods on objects.
Code:
#{user.getName()}
#{'spring boot'.toUpperCase()}
#{'hello'.length()}
Explanation
Nested object navigation allows an expression to access properties several levels deep.
Code:
#{employee.department.manager.name}
Explanation
Safe navigation can be used when an intermediate object might be null.
Code:
#{employee?.department?.manager?.name}
Explanation
SpEL can access collection elements using index-based navigation.
Code:
#{employees[0].name}
#{employees[1].name}