发送post请求:
1.创建XMLHttpRequest对象 let xhr = new XMLHttpRequest(); 2.建立对服务器的调用。第一个参数是对GET或者POST, 第二个参数可以是相对或者绝对路径, 第三个参数: true异步/false同步, 默认为true xhr.open("POST", "/upimage", true); 3.向服务器发送请求, 仅用于post xhr.send(formData); 4.服务器的响应,表示一个串 xhr.responseText;
例子:
js:
let xhr = new XMLHttpRequest();
xhr.open("POST", "/upimage", true);
xhr.send(formData);
xhr.responseText;
这里的formData是图片
获取canvas中的图片链接:
HTML5 Canvas转化成图片后上传服务器_粉红猪。。。的博客-CSDN博客
Controller层:
@RequestMapping("/upimage")
public v