运行springboot的时候访问本地图片地址的问题
2024-10-20 15:51:36
@Configuration
public class MyConfigrauration implements WebMvcConfigurer { /**
* 当有请求经过【/myUpload/**】
* 访问本地文件【E/upload】
* @param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/myUpload/**")
.addResourceLocations("file:E:/upload/");
}
}
//文件上传成功后的钩子,response为服务端返回的值,file为当前上传的文件封装成的js对象
handleAvatarSuccess(response, file) {
console.log(response);
console.log(file);
//访问的时候地址端口再加上请求的名字后端拦截
this.imageUrl = "http://localhost:9001/myUpload/" + response.data
if (response.flag) {
this.$message({
type: 'success',
message: response.message
});
this.formData.img = response.data;
} else {
this.$message({
type: 'error',
message: response.message
});
} },
最新文章
- Red Hat Linux9命令行--修改补充中
- Balance_01背包
- C#实现Dll(OCX)控件自动注册的两种方法
- (UVALive 7261)Xiongnu's Land 二分
- tomcat配置301重定向(urlRewrite URL重写)
- 学习Swift--属性
- Linux正则表达式grep与egrep
- 栈实现java
- Zookeeper分享
- LeetCode4. Median of Two Sorted Arrays---vector实现O(log(m+n)--- findkth
- xiaowuga poj3735—Training little cats(特殊操作转化为矩阵操作)
- babel 基本
- css-实现子元素垂直居中
- [深入Maven源代码]maven绑定命令行参数到具体插件
- C#.NET常见问题(FAQ)-如何修改Form不能修改窗体大小
- mysqldump备份脚本---待完善
- rpm使用方法
- 编译可移植的python
- 基于jQuery仿淘宝产品图片放大镜代码
- C# 获取命名空间对应的程序集位置
热门文章
- java RSA加密
- Grafana 系列文章(二):使用 Grafana Agent 和 Grafana Tempo 进行 Tracing
- 使用 NineData 实现备份集的实时查询
- 【单片机】nRF52832 实现停止蓝牙广播接口
- 12月13日内容总结——路由分发、名称空间、虚拟环境、视图层三板斧、JsonResponse对象、request对象获取文件、视图层FBV与CBV的源码剖析、模版层简介
- Arm-Linux子系统的互相Notify
- OpenMP Sections Construct 实现原理以及源码分析
- 10分钟搞定简易MVVM
- Spring框架-IoC核心
- 了解舵机以及MG996R的控制方法