小工具知识网

当前位置: 首页 > 行业知识 > 微信小程序显示流格式照片

行业知识

微信小程序显示流格式照片

2026-10-27 02:58:43 来源:互联网转载

1.服务端,java代码,用于将图片转为文件流返回给前端

import java.nio.file.Files;import java.nio.file.Path;import java.nio.file.Paths;import org.springframework.core.io.Resource;import org.springframework.core.io.UrlResource;import org.springframework.http.HttpHeaders;import org.springframework.http.MediaType;import org.springframework.http.ResponseEntity;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class Demo {    @GetMapping("/aaaaaa")    public ResponseEntity getImage(String imageName) throws Exception {        // 构建图片的路径        Path imagePath = Paths.get("D:\1.png");                // 检查文件是否存在        if (!Files.exists(imagePath)) {            throw new Exception("Image not found");        }                // 将图片文件转换为Resource对象,以便Spring管理        Resource resource = ne
()()

上一篇:织梦系统备份全攻略,简单教程,轻松掌握备份技巧!

下一篇:电脑怎么安装音频服务器?