【springBoot】SpringBoot在引用webjars静态资源,路径应该这么写

Spring Boot 对静态资源映射提供了默认配置

Spring Boot 默认将 /** 所有访问映射到以下目录:

classpath:/static
classpath:/public
classpath:/resources
classpath:/META-INF/resources(需手动创建)

html引入静态文件应该这样写

//css
<
link rel="stylesheet" type="text/css" href="/webjars/Semantic-UI/2.4.1/semantic.css">
//js
<script type="application/javascript" src="/webjars/Semantic-UI/2.4.1/semantic.min.js"></script>
//在使用thymeleaf模板的情况下
//css
<link rel="stylesheet" type="text/css" href="/webjars/Semantic-UI/2.4.1/semantic.css" th:href="@{/webjars/Semantic-UI/2.4.1/semantic.css}">
//js <script type="application/javascript" src="/webjars/Semantic-UI/2.4.1/semantic.min.js" th:src="@{/webjars/Semantic-UI/2.4.1/semantic.min.js}"></script>
原文地址:https://www.cnblogs.com/aioe/p/13320929.html