补充
https://www.cnblogs.com/teach/p/5791029.html
背景
前后端分离:postman模拟表单
ssm框架
技术
json格式的数据的传输:json数据就理解成String类型,然后将String类型转换成对象
- 提交表单使用@RequestParm(value=“file” , required= true) MultipartFile
- 使用到net.sf包下面的JSONObject对象
- 将传参String类型进行转换成实体对象
- jsonObject=JSONObject.fromObject(history1);
- JSONObjext.toBean(jsonObject,History.class)
@RequestMapping(value = "/addHistory", method = RequestMethod.POST)
@ResponseBody
public Object addHistory(@RequestParam(value = "fileInfo", required = true) String history1,
@RequestParam(value = "file", required = true) MultipartFile file
) {
//历史记录存入数据库
JSONObject json = JSONObject.fromObject(history1);
History histo