diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/builders/WebSecurity.java b/config/src/main/java/org/springframework/security/config/annotation/web/builders/WebSecurity.java index 09926afc805..02f50146aa9 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/builders/WebSecurity.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/builders/WebSecurity.java @@ -344,7 +344,10 @@ private RequestMatcherEntry> getRequestMat if (filter instanceof AuthorizationFilter) { AuthorizationManager authorizationManager = ((AuthorizationFilter) filter) .getAuthorizationManager(); - privilegeEvaluators.add(new AuthorizationManagerWebInvocationPrivilegeEvaluator(authorizationManager)); + AuthorizationManagerWebInvocationPrivilegeEvaluator evaluator = new AuthorizationManagerWebInvocationPrivilegeEvaluator( + authorizationManager); + evaluator.setServletContext(this.servletContext); + privilegeEvaluators.add(evaluator); } } return new RequestMatcherEntry<>(securityFilterChain::matches, privilegeEvaluators);