本文主要是介绍使用formData向后台传递数组对象,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.前端
let formDatas = new FormData(); let sealValues = t.sealValues; formDatas.append('pdfFile', t.parsePdfFile); for(let i=0,len=sealValues.length;i<len;i++){let locationInfo = sealValues[i];formDatas.append('sealLocationInfoList['+i+'].posX',locationInfo.posX);formDatas.append('sealLocationInfoList['+i+'].posY',locationInfo.posY);formDatas.append('sealLocationInfoList['+i+'].signOnPage',locationInfo.signOnPage);formDatas.append('sealLocationInfoList['+i+'].sealId',locationInfo.sealId); }
2.后端接收
@RequestMapping(path = "/stamp", method = RequestMethod.POST)public ResponseEntity<Map<String, Object>> stamp(HttpServletRequest req,@Param("pdfFile") MultipartFile pdfFile, SealLocationInfoRequest request) {//}
3.后台映射对象
public class SealLocationInfoRequest implements Serializable {private static final long serialVersionUID = 2392716281569231777L;private Long contractId;private String filePath;private List<SealLocationInfo> sealLocationInfoList;
}
public class SealLocationInfo implements Serializable {private static final long serialVersionUID = -8706741125508276806L;private Integer posType;//定位或关键字private float posX;private float posY;private String signOnPage;private Long sealId;private String key;private float width;private Integer signType;//2.骑缝章 1.其他
}
这篇关于使用formData向后台传递数组对象的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!