补充
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

本文主要介绍了在SSM框架下如何处理包含文件的表单提交,涉及到使用MultipartFile对象进行单文件和多文件上传,以及文件保存到本地或服务器的实现方法。通过postman模拟表单请求,结合json数据转换实体对象进行操作。
最低0.47元/天 解锁文章
7768

被折叠的 条评论
为什么被折叠?



