当前位置:网站首页>静态资源映射
静态资源映射
2022-07-29 10:04:00 【胡桃姓胡,蝴蝶也姓胡】
我们有的时候要使用静态资源映射,我们在创建SpringBoot项目的时候,resources目录底下有static和template,系统会默认在这两个目录底下寻找前端文件,但是我们这个项目的目录是这样的。

这就要求我们使用静态资源映射,让系统从backend和front里面读取前端文件。
代码如下:
@Slf4j
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
// 设置静态资源映射
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
log.warn("开始进行静态资源映射=========");
registry.addResourceHandler("/backend/**")
.addResourceLocations("classpath:/backend/");
registry.addResourceHandler("/front/**")
.addResourceLocations("classpath:/front/");
}
}addResourceHandler是访问路径,addResourceLocations是映射后的真实路径,结尾必须要加上/,不然找不到。
边栏推荐
- A Zuo's realm
- Sed, regular expression of shell programming
- 开放原子开源基金会黄金捐赠人优博讯携手合作伙伴,助力OpenHarmony破圈!
- Skiasharp's WPF self drawn bouncing ball (case version)
- 机器学习之线性回归(最小二乘法手写+sklearn实现)
- Shell notes (super complete)
- 程序员脱离单身的一些建议
- [C language] minesweeping (recursive expansion + marking function)
- [jetson][转载]jetson上安装pycharm
- TMS320C6000_ Tms320f28035 Chinese data manual
猜你喜欢

Why does the system we developed have concurrent bugs? What is the root cause of concurrent bugs?

Talk about multithreaded concurrent programming from a different perspective without heap concept

【C语言】扫雷(递归展开 + 标记功能)

Manually build ABP framework from 0 -abp official complete solution and manually build simplified solution practice

根据给定字符数和字符,打印输出“沙漏”和剩余数

Source code analysis of senparc.weixin.sample.mp

7.9-7.17 new features and grammar of learning plan ES6

Pytest+allure generate test report

高效能7个习惯学习笔记

Examples of specific usage of diagnostic instructions in s7-1200 and s7-1500 (led+devicestates+modulestates)
随机推荐
开放原子开源基金会黄金捐赠人优博讯携手合作伙伴,助力OpenHarmony破圈!
SiC Power Semiconductor Industry Summit Forum successfully held
[FPGA tutorial case 18] develop low delay open root calculation through ROM
CS research assurance experience in 2021 (VI): system filling + some thoughts
Soft exam summary
Talk about multithreaded concurrent programming from a different perspective without heap concept
Anfulai embedded weekly report no. 273: 2022.07.04--2022.07.10
Dimensionality reduction and mathematical modeling after reading blog!
After the thunderstorm of two encryption companies: Celsius repayment guarantee collateral, three arrow capital closed and disappeared
Source code analysis of senparc.weixin.sample.mp
还是有机会的
跟着李老师学线代——矩阵(持续更新)
Efficient 7 habit learning notes
English语法_不定代词 - 常用短语
我的问题解决记录1:类上使用了@Component注解,想要使用这个类中的方法,便不能直接new,而应该使用# @Autowired进行注入,否则会报错(如空指针异常等)
Yin Yi: my learning and growth path
Geeer's happiness | is for the white whoring image! Analysis and mining, NDVI, unsupervised classification, etc
[AAAI] attention based spatiotemporal graph convolution network for traffic flow prediction
[fortran]vscode configure FORTRAN to run Hello World
Sublime Text3 设置不同文件不同缩进