//返回响应内容类型
response.setContentType("audio/wav");
OutputStream out = response.getOutputStream();
老是报audio/wav 错误 说with preset Content-Type 'audio/wav'
改成response.setContentType("application/octet-stream");后可以传数据过去,但是不是音频文件,不知道前端能不能解析到
把这个博客甩给前端就行了前端如何接收后端返回content-Type为application/octet-stream格式的音频文件_天一城的博客-CSDN博客_content-type: application/octet-stream
FileInputStream inputStream = new FileInputStream("text"+uuid+".wav");
int i = inputStream.available();
byte[] buff = new byte[i];
inputStream.read(buff);
//关闭输入流
inputStream.close();
//返回响应内容类型
response.setContentType("application/octet-stream");
OutputStream out = response.getOutputStream();
out.write(buff);
out.close();
这是完整的代码