CSS 未链接且无法与 Spring Boot 应用程序一起使用

标签 css spring spring-boot

enter image description here

这是我的元素的图片。 我在 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 访问它们

附言here you can find a simple good structured example.

关于CSS 未链接且无法与 Spring Boot 应用程序一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43333249/

相关文章:

javascript - 从 div 制作 ahref

java - 没有配置 CurrentSessionContext

xml - 我可以在 Spring Boot 应用程序中使用 xml 属性文件而不是 application.properties 吗?

html - 在无序列表中保持所有子节点缩进

html - absmiddle 和 middle 和有什么不一样

spring - ConnectController.setApplicationUrl() 返回 NullPointerException

ajax - Tomcat 为每个请求创建一个新 session

spring - 使用 Kotlin 解决 Spring Boot Rest Controller 中的单例

javascript - 通过搜索最近的类(class)来更改类(class)

java - Java属性文件中等号和冒号的区别