有没有办法在Spring MVC中将JSON对象嵌入到模型属性中? 例如,在客户端:
var obj = JSON.parse(user); //user is a json string containing user object info
var formdata = new FormData();
formdata.append("userInfo",obj);
在服务器端:
@RequestMapping(value = "/here", method = {
RequestMethod.POST, RequestMethod.GET }, headers = "content-type=multipart/form-data")
@ResponseBody
public String doSomething(
@ModelAttribute MyForm myForm,
HttpServletRequest request,
HttpServletResponse response
) {
User user = myForm.getUserInfo();
}