如何使用ajax将canvas对象发送到java

时间:2022-12-01 16:40:37

I want to send a canvas image object to the server using ajax. After creating the canvas image

我想使用ajax将canvas画面对象发送到服务器。创建画布图像后

 var dataURL = canvas.toDataURL();

$.ajax({
    type: "POST",
    url: "uploadProfPic",
    data: { userId: user, imgBase64: dataURL }
})

in the controller I tried like

在我试过的控制器中

@RequestMapping(value = "/uploadProfPic",method = RequestMethod.POST)
public @ResponseBody uploadProfPic(@RequestParam(value="imageBase64", defaultValue="")String imageBase64, String userId){

    return userId;
}

In @RequestParam what will i write to get the canvas object?

在@RequestParam中我会写什么来获取canvas对象?

1 个解决方案

#1


0  

@RequestParam String imgBase64

As you are transmitting the data as a string.

当您将数据作为字符串传输时。

#1


0  

@RequestParam String imgBase64

As you are transmitting the data as a string.

当您将数据作为字符串传输时。