这是我的元素的图片。 我在 static/css 文件夹中有我的 css 文件,我试图将它与我的 index.jsp 页面链接,但它不起作用。 注意:硬刷新,缓存清除一切都已完成,我已经尝试了 10 多次。 :( 还有其他方法可以将 css 与 spring boot 应用程序链接起来吗?
最佳答案
在 Spring-boot 文档中,您可以阅读 Spring-boot 默认读取静态资源的位置。
By default Spring Boot will serve static content from a directory called
/static (or /public or /resources or /META-INF/resources)
in the classpath or from the root of the ServletContext. It uses the ResourceHttpRequestHandler from Spring MVC so you can modify that behavior by adding your own WebMvcConfigurerAdapter and overriding the addResourceHandlers method.
如果您将静态文件的位置更改为默认位置,您应该能够通过 /css/style.css
访问它们
关于CSS 未链接且无法与 Spring Boot 应用程序一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43333249/