当前位置:网站首页>静态资源映射
静态资源映射
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是映射后的真实路径,结尾必须要加上/,不然找不到。
边栏推荐
- 全面、详细的SQL学习指南(MySQL方向)
- A sharp tool for data visualization Seaborn easy to get started
- Intel joins hands with datawhale to launch learning projects!
- Examples of specific usage of diagnostic instructions in s7-1200 and s7-1500 (led+devicestates+modulestates)
- 2021年CS保研经历(四):西交软院预推免、信工所三室预推免
- 造型科幻、标配6安全气囊,风行·游艇11.99万起售
- JS 实现全屏效果
- SiC功率半导体产业高峰论坛成功举办
- QoS quality of service five traffic shaping of QoS boundary behavior
- 【微信小程序】接口生成自定义首页二维码
猜你喜欢

【黑马早报】每日优鲜回应解散,多地已无法下单;李斌称蔚来将每年出一部手机;李嘉诚欲抄底恒大香港总部大楼;今年国庆休7天上7天...

这是一份不完整的数据竞赛年鉴!

Print out the "hourglass" and the remaining number according to the given number of characters and characters

Geeer's happiness | is for the white whoring image! Analysis and mining, NDVI, unsupervised classification, etc

综合设计一个OPPE主页--页面的底部

Unity3d empty package APK error summary

高效能7个习惯学习笔记

Which hero is the most difficult for lol in terms of code?

Explanation of C value type and reference type

【C语言】扫雷(递归展开 + 标记功能)
随机推荐
Notes for Resume Writing
[HFCTF 2021 Final]easyflask
Only simple function test? One article takes you to advanced interface automatic testing technology in 6 steps
Div horizontal arrangement
MySQL million level data migration practice notes
Read Plato farm's eplato and the reason for its high premium
汉源高科千兆2光6电导轨式网管型工业级以太网交换机支持X-Ring冗余环网一键环网交换机
node(二)
一文读懂Plato Farm的ePLATO,以及其高溢价缘由
综合设计一个OPPE主页--页面的底部
Dynamics 365Online 如何自定义商机关闭窗体
Is it safe to open an account online now? Do you want to know that you must go to the business hall to open an account now?
shell编程之sed,正则表达式
Talk about multithreaded concurrent programming from a different perspective without heap concept
Network picture to local picture - default value or shortcut key
CS research assurance experience in 2021 (VI): system filling + some thoughts
Summary of JD internship written examination questions
不堆概念、换个角度聊多线程并发编程
Sed, regular expression of shell programming
通俗易懂讲解梯度下降法!