💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
**1. SpringBoot中默认的静态资源位置** ```java public class ResourceProperties { private static final String[] CLASSPATH_RESOURCE_LOCATIONS = new String[] { "classpath:/META-INF/resources/" /resources/META-INF/resources/ , "classpath:/resources/" /resources/resources/ , "classpath:/static/" /resources/static/ , "classpath:/public/" /resources/public/ }; private String[] staticLocations; private boolean addMappings; ``` **2. `pom.xml`引入devtools** ```html <!-- 热重启组件,它对于静态资源的访问尤为重要 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> ``` **3. 静态资源默认放在`resources/static`目录下** ``` |—— 项目名 | |—— src | | |—— main | | | |—— java | | | |—— resources | | | | |—— static #放一些静态资源,js、css、图片等 | | | | | |—— assets | | | | | | |—— jquery.min.js | | | | |—— templates | | | | | |—— account.html ``` **4. 页面引入jquery** ```html <script type="text/javascript" src="/assets/jquery.min.js"></script> ```