当前位置:网站首页>静态资源映射
静态资源映射
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是映射后的真实路径,结尾必须要加上/,不然找不到。
边栏推荐
- Manually build ABP framework from 0 -abp official complete solution and manually build simplified solution practice
- “为机器立心”:朱松纯团队搭建人与机器人的价值双向对齐系统,解决人机协作领域的重大挑战
- 这是一份不完整的数据竞赛年鉴!
- "Focus on machines": Zhu Songchun's team built a two-way value alignment system between people and robots to solve major challenges in the field of human-computer cooperation
- 全面、详细的SQL学习指南(MySQL方向)
- Docker安装Redis、配置及远程连接
- Why does the system we developed have concurrent bugs? What is the root cause of concurrent bugs?
- 云服务大厂高管大变阵:技术派让位销售派
- This developer, who has been on the list for four consecutive weeks, has lived like a contemporary college student
- 【微信小程序】接口生成自定义首页二维码
猜你喜欢
![[FPGA tutorial case 18] develop low delay open root calculation through ROM](/img/c3/02ce62fafb662d6b13aedde79e21fb.png)
[FPGA tutorial case 18] develop low delay open root calculation through ROM

Only simple function test? One article takes you to advanced interface automatic testing technology in 6 steps

Efficient 7 habit learning notes

尹伊:我的学习成长路径

英特尔联合Datawhale,发布学习项目!

【AAAI】用于交通流预测的基于注意力的时空图卷积网络

Knowledge points of common interview questions: distributed lock

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

造型科幻、标配6安全气囊,风行·游艇11.99万起售

关系型数据库之MySQL8——由内而外的深化全面学习
随机推荐
【配置相关】
The purpose of DDD to divide domains, sub domains, core domains, and support domains
[FPGA tutorial case 19] factorial operation through multiplier
My problem solving record 1: the @component annotation is used on the class. If you want to use the methods in this class, you can't directly new, but should use @autowired for injection, otherwise an
What is Cartland number? What are the applications?
SiC Power Semiconductor Industry Summit Forum successfully held
JS 实现全屏效果
【日志框架】
Sublime Text3 set different indents for different files
Be tolerant and generous
CS research assurance experience in 2021 (VI): system filling + some thoughts
【论文阅读】Q-BERT: Hessian Based Ultra Low Precision Quantization of BERT
全面、详细的SQL学习指南(MySQL方向)
通俗易懂讲解梯度下降法!
智慧解决问题
网络图片转换本地图片 - 默认值或快捷键
Harmonyos 3.0 release!
Are you familiar with the redis cluster principle of high paid programmers & interview questions series 122? How to ensure the high availability of redis (Part 2): cluster mechanism and principle, clu
机器学习之线性回归(最小二乘法手写+sklearn实现)
Read Plato farm's eplato and the reason for its high premium