admin 管理员组

文章数量: 1086019

I have a OncePerRequestFilter:

@Component
public class RestrictedSettingsFilter extends OncePerRequestFilter {
  @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        ContentCachingResponseWrapper responseWrapper = new ContentCachingResponseWrapper(response);
        try {
            filterChain.doFilter(request, responseWrapper);
            if (responseWrapper.isCommitted()) {
                log.warn("The response has already been committed, cannot modify it");
                return;
            }
            // ...
        } finally { responseWrapper.copyBodyToResponse(); }
}

and I manually register it (probably should be done by annotations, but the project is a bit old):

@Bean
public FilterRegistrationBean<Filter> restrictedSettingsFilter(RestrictedSettingsFilter restrictedSettingsFilter) {
        FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>();
        filterRegistrationBean.setFilter(restrictedSettingsFilter);
        filterRegistrationBean.setOrder(Ordered.LOWEST_PRECEDENCE); 
        return filterRegistrationBean;
}

From what I understand, when I set its order to LOWEST_PRECEDENCE, it should be resolved last in pre-processing and first in post-processing. Therefore, the response should not be committed yet. But I get The response has already been committed, cannot modify it message. On the other hand, when I set the order to HIGHEST_PRECEDENCE, it started working again. How is it possible?

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)