代码部分
@PostMapping(value = "/student/uploadandaddstudent")
@ResponseBody
public String fileUploads(@RequestParam("file") MultipartFile file, HttpServletResponse response, @RequestParam("newstudent") String newstudent) throws IOException {
Student addstudent = new ObjectMapper().readValue(newstudent, Student.class);//将json字符串解析为对象
return "success";
}
讲解
请前端传递的json字符串解析为一个java对象