Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 未在spring security中加载CSS文件_Spring Boot_Spring Security_Thymeleaf - Fatal编程技术网

Spring boot 未在spring security中加载CSS文件

Spring boot 未在spring security中加载CSS文件,spring-boot,spring-security,thymeleaf,Spring Boot,Spring Security,Thymeleaf,我不熟悉spring boot和spring security。在这里,我试图用thymeleaf运行SpringBootWeb应用程序,但当我试图在加载了css的浏览器页面中点击url时 在Firefox下面显示警告 严格的传输安全性:与站点的连接不可信,因此忽略了指定的标头 加载源为“”的文件失败https://localhost:xxxx/assets/bootstrap/js/bootstrap.min.js“ 在下面的Chrome中显示错误 拒绝应用来自“”的样式https://loc

我不熟悉spring boot和spring security。在这里,我试图用thymeleaf运行SpringBootWeb应用程序,但当我试图在加载了css的浏览器页面中点击url时

在Firefox下面显示警告

严格的传输安全性:与站点的连接不可信,因此忽略了指定的标头

加载源为“”的文件失败https://localhost:xxxx/assets/bootstrap/js/bootstrap.min.js“

在下面的Chrome中显示错误

拒绝应用来自“”的样式https://localhost:xxxx/assets/dist/css/login.css'因为其MIME类型“application/json”不是受支持的样式表MIME类型,并且启用了严格的MIME检查

拒绝应用来自“”的样式https://localhost:xxxx/assets/bootstrap/css/bootstrap.min.css'因为其MIME类型'application/json'不是受支持的样式表MIME类型,并且启用了严格的MIME检查


我的应用程序出了什么问题。

只是一个一般性提示:如果您使用的是像eclipse这样的IDE,请确保所有文件都在各自的文件夹中,并在代码中对文件路径进行计数器检查

如果将文件从文件系统复制到项目文件夹中,还必须刷新项目

其次,转到SecurityConfiguration类文件,在其中添加/assets/**如下,以防您没有这样做:

//...Other code here
private static final String[] PUBLIC_MATCHERS = {
            "/",
//...other code ....
            "/assets/**"
    };

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests().
            antMatchers(PUBLIC_MATCHERS).
            permitAll().anyRequest().authenticated();

//other code...
}
}
如果您的案例中所有这些都失败,请尝试对引导文件使用cdn,检查以下内容:
如果cdn可用于引导,则您知道您的路径引用或安全配置中存在问题。

可能存在@Alien的重复项它与我的问题无关我猜您的样式表交付被spring Security阻止,并且浏览器收到某种错误消息。尝试在浏览器中打开样式表。@flooke浏览器中有样式表吗?@Durga在浏览器中打开页面,然后右键单击打开“源代码”视图,类似于“源代码”视图。在这里,您会发现一个类似于