springBoot 配置url 访问图片
2024-08-27 15:30:06
需要添加依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
配置:
@Configuration
public class WebMvcConfigurer extends WebMvcConfigurerAdapter { @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//和页面有关的静态目录都放在项目的static目录下
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
//上传的图片在D盘下的OTA目录下,访问路径如:http://localhost:8080/xxx.jpg
} }
浏览器正常访问:
最新文章
- .NET使用NPOI2.0导入导出Excel
- SQL触发器、事物
- 十日谈 (share)
- 传统三层结构和MVC之于贫血模式和充血模式以及领域建模
- (原)matlab中使用mex编译多个cpp文件
- MVVMLight Toolkit在Windows Phone中的使用扩展之一:在ViewModel中实现导航,并传递参数
- USACO Section 1.3 Combination Lock 解题报告
- 使用clone
- C#线程安全使用(二)
- 多线程学习笔记-深入理解ThreadPoolExecutor
- How to detect, enable and disable SMBv1, SMBv2, and SMBv3 in Windows and Windows Server
- QtQuick大坑笔记之Http的Get与Post操作(带cookie)
- Linux 命令整理-tailf
- 团队项目之UML图设计
- yocto-sumo源码解析(八): ProcessServer
- 20135316王剑桥 linux第六周课实验笔记
- java基础3 循环语句:While 循环语句、do while 循环语句、 for 循环语句 和 break、continue关键字
- js 操作对象的引用和操作实际对象的区分
- 用webpy实现12306余票查询
- PIP源使用国内镜像
热门文章
- Pycharm Debug 问题
- selenium2环境搭建----基于python语言
- gym102215题解
- 2018icpc宁夏邀请赛_L_Continuous Intervals
- ArcGis执行StartEditing(true)时,winform程序直接崩溃.
- sublime text 3 环境设置
- RateLimiter 源码分析(Guava 和 Sentinel 实现)
- 表格强制换行 table-layout:fixed
- Git 设置 用户名 和 邮箱
- 几个常用I/O函数用法(printf,fprintf等)