Spring Boot mapping rules for static resources

Rule number one: All "/ webjars / **" requests to classpath: / META-INF / resources / webjars / find resources

webjars: jar package introduced by way of static resources

Example: the introduction of jquery.js file

pom.xml file, add the following dependence:

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>jquery</artifactId>
    <version>3.4.1</version>
</dependency>

jar package directory is as follows:

Access localhost: 8080 / webjars / jquery / 3.4.1 / jquery.js you can get the file.

 

Rule number two: "/ **" Any resource access current project (static resource file folder)

"classpath:/META-INF/resources/"
"classpath:/resources/"
"classpath:/static/"
"classpath:/public/"
"/": The current root path of the project

The corresponding file folder in the following figure classpath, classpath and resource means java

 

Folder to find 8080 / abc === to the above description of several file abc: localhost

For example: access static folder of images / person.jpg

Access path: localhost: 8080 / images / person.jpg

 

Rule number three: Welcome page for all index.html page static resource folder, by "/ *" Mapping

Such as: localhost: 8080 /

 

Rule Four: All "** / favicon.icon" look at all static resources folder, for setting web icon

Guess you like

Origin www.cnblogs.com/YeHuan/p/12103766.html