spring security - how to remove cache control in certain url pattern

前端 未结 2 1320
日久生厌
日久生厌 2021-01-14 13:16

I am trying to filter some url pattern to caching. What I have attempted is put some codes into WebSecurityConfigurerAdapter implementation.

 @O         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-14 14:01

    I solved this with Filter. Below is part of my implementation of AbstractAnnotationConfigDispatcherServletInitializer. In onStartup method override.

    FilterRegistration.Dynamic springSecurityFilterChain = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
    if(springSecurityFilterChain != null){
        springSecurityFilterChain.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/render/*", "/service/*");
        // I removed pattern url "/image/*" :)
    }
    

    What I have done is remove /image/* from MappingUrlPatterns. Thanks for your answers!

提交回复
热议问题