During development, we may need to open some static resource files to front-end access, but we don’t want to stuff these files into the project (mainly because the files take up too much memory), so what should we do?
In fact, springboot provides a capability that allows you to open any folder in the local directory to front-end access.
1. First, we create a new folder on the local disk, like this
Need to pay attention: which disk your project is on, you will create this folder on that disk
2. Then we put a file in this folder
3. Then we add configuration in the configuration file of springboot
spring:
# 静态文件路径映射
resources:
static-locations: file:/upload-file
In this way, we /upload-file
can access the folder as a network resource
4. Start the project
5. Then we can access this 1.jpg file from the browser
OK, the test was successful
write to idiot know