Skip to content

Commit

Permalink
GrailsWebRequestFilter needs ApplicationContext set because it is App…
Browse files Browse the repository at this point in the history
…licationContextAware
  • Loading branch information
codeconsole committed Nov 18, 2024
1 parent 10293ad commit 2a0b7d2
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,9 +54,11 @@ public FilterRegistrationBean<Filter> hiddenHttpMethodFilter() {

@Bean
@ConditionalOnMissingBean(GrailsWebRequestFilter.class)
public FilterRegistrationBean<Filter> grailsWebRequestFilter() {
public FilterRegistrationBean<Filter> grailsWebRequestFilter(ApplicationContext applicationContext) {
FilterRegistrationBean<Filter> 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,
Expand Down

0 comments on commit 2a0b7d2

Please sign in to comment.