java怎么上传语音文件,如何将音频Blob(数据)文件从JavaScript发送到Java Server(Action)?...

本文档介绍如何在Struts2应用程序中,将JavaScript中的录音音频Blob文件通过Ajax发送到Java服务器(Action)类。提供了一个XML配置示例,展示了在服务器端接收并处理FormData的方法。
摘要由CSDN通过智能技术生成

We are using Struts2 Application wherein I want to send the recorded audio blob file which is in JavaScript, to Java Server (Action Class). I am using the following Ajax code to send the blob file.

Javascript:

var xhr=new XMLHttpRequest();

xhr.οnlοad=function(e) {

if(this.readyState === 4) {

console.log("Server returned: ",e.target.responseText);

}

};

var fd=new FormData();

fd.append("filename.wav",blob);

xhr.open("POST","getAudio",true);

xhr.send(fd);

My method in action class is getAudio(). So, since it is a data file, how can i receive it in my method and suggest the appropriate xml configuration to receive the same. It would be great, if any ideas. Thanks in advance.

解决方案

In Struts2 you can create xml config

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值