禁止访问.css文件(主资源文件夹中的特定文件夹)

时间:2018-05-15 23:02:39

标签: java spring-boot spring-security access

我在网上搜索了几个小时的解决方案。我想访问rm -rf /var/lib/cassandra/*,但不能访问localhost/index.html

我的静态资源来自外部文件夹,而filee树显而易见:

localhost/layout/style.css

到目前为止,我尝试过的所有事情都禁止访问index.html,index和style.css都可以访问。

我在网上发现的最有意义的是:

->site
   ->layout
      ->style.css
   ->index.html

但是当我使用@Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers("/*.html").permitAll(); // http.authorizeRequests().antMatchers("/**").permitAll(); super.configure(http); } @Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/layout/**"); super.configure(web); } 时,它会显示css文件。

我的localhot/layout/style.css

WebMvcConfigurerAdapter

启动时的注释:

@Configuration
public class StaticResourceConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("file:mylocation/site/");
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("redirect:/index.html");
    }
}

能够在布局文件夹中查看index.html而不是所有css文件的方法是什么?

P.S:也许这甚至不可能?

0 个答案:

没有答案