前段给springboot2传送图片,图片的回显的问题,也是需要重启服务器才能访问图片的问题,就是热部署的问题

以2021的idea为例子

一般都是idea的配置的问题,我们需要修改两个配置

第一步设置:

2,第二部设置

3,postman测试

 4,拿到地址去访问

成功出现

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要实现Spring Boot + Vue + ElementUI 的图片回显功能,需要以下步骤: 1. 在Vue中使用ElementUI的Upload组件上传图片,并将上传成功后的图片地址保存在Vue的data中。 2. 在Spring Boot的Controller中编写接收图片上传请求的方法,将上传的图片保存到服务器上,并返回图片访问地址。 3. 在Vue中使用img标签展示上传成功的图片,将img标签的src属性设置为上传成功后返回的图片地址。 下面是一个简单的示例代码: Vue代码: ``` <template> <div> <el-upload class="upload-demo" :action="uploadUrl" :on-success="handleUploadSuccess" :show-file-list="false"> <el-button slot="trigger" size="small" type="primary">点击上传</el-button> </el-upload> <img v-if="imageUrl" :src="imageUrl" /> </div> </template> <script> export default { data() { return { imageUrl: '', uploadUrl: 'http://localhost:8080/upload' } }, methods: { handleUploadSuccess(response) { this.imageUrl = response.data.url; } } } </script> ``` Spring Boot代码: ``` @RestController public class UploadController { @PostMapping("/upload") public ResponseEntity<String> upload(@RequestParam("file") MultipartFile file) { try { // 保存上传的文件到服务器上 String fileName = file.getOriginalFilename(); String filePath = "path/to/save/" + fileName; File dest = new File(filePath); file.transferTo(dest); // 返回图片访问地址 String imageUrl = "http://localhost:8080/images/" + fileName; return ResponseEntity.ok(imageUrl); } catch (Exception e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); } } } ``` 注意:上述代码仅供参考,具体实现需要根据自己的需求进行适当的修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

菜菜抱抱

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值