我正在尝试将 wicket 与 spring-boot 集成,并且我正在尝试将样式表简单地添加到一个非常简单的页面。所以我像往常一样在 Spring-boot 中将样式表放在 resources/static/css
中,事实上,我看到它已被提供(通过指向 CSS URL)。
另一方面,我没有在源码中看到(Chrome中的Ctrl+Shift+I),所以我检查了浏览器日志,发现了以下错误:
Refused to load the stylesheet 'http://localhost:8080/css/custom.css' because it violates the following Content Security Policy directive: "style-src 'none-...."
我没有启用了 Spring Security,因为我仍在尝试了解 Wicket 的工作原理,但如果需要我可以做到。
有人可以提出解决方案吗?谢谢。
最佳答案
这是由 Wicket 的 CSP 引起的(内容安全政策)。
您可以通过在 YourApplication#init()
方法中添加以下行来禁用它:
getCspSettings().blocking().disabled();
如果您想重新启用它,您将需要阅读更多关于 CSP 的内容。
关于spring-boot - 使用 wicket 和 spring-boot 的浏览器拒绝样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70419199/