diff --git a/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersAutoConfiguration.java b/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersAutoConfiguration.java index 7273ab0c52..acd61f6c43 100644 --- a/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersAutoConfiguration.java +++ b/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersAutoConfiguration.java @@ -14,6 +14,7 @@ import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.web.filter.CharacterEncodingFilter; @@ -53,9 +54,11 @@ public FilterRegistrationBean hiddenHttpMethodFilter() { @Bean @ConditionalOnMissingBean(GrailsWebRequestFilter.class) - public FilterRegistrationBean grailsWebRequestFilter() { + public FilterRegistrationBean grailsWebRequestFilter(ApplicationContext applicationContext) { FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - registrationBean.setFilter(new GrailsWebRequestFilter()); + GrailsWebRequestFilter grailsWebRequestFilter = new GrailsWebRequestFilter(); + grailsWebRequestFilter.setApplicationContext(applicationContext); + registrationBean.setFilter(grailsWebRequestFilter); registrationBean.setDispatcherTypes(EnumSet.of( DispatcherType.FORWARD, DispatcherType.INCLUDE,