Spring Expression Language enables fine-grained access control by letting security annotations evaluate runtime expressions—referencing the current user, method arguments, or bean methods—rather than being limited to static role names.
An expense-approval method uses @PreAuthorize("hasRole('MANAGER') and #expense.amount <= 5000") so managers can only approve expenses under a certain threshold without a separate hardcoded rule per amount tier.
@PreAuthorize("hasRole('MANAGER') and #expense.amount <= 5000")
public void approveExpense(Expense expense) {
// approval logic
}A concise interview answer is
SpEL inside @PreAuthorize or @PostAuthorize lets me write expressions that go beyond static roles—checking method arguments, calling custom permission beans, or inspecting the returned object. That gives fine-grained, context-aware access control tailored to the specific business rule rather than a blunt role check.
Last updated: 11 November 2026
Previous question: Explain salting and its usage in Spring Security.
Next question: What are AuthenticationManager and ProviderManager in Spring Security?