我有一个spring boot API,我想发布一些变量。
@RequestMapping(value = "/previewDocument", method = RequestMethod.POST, produces = "application/pdf")
public byte[] previewDocument(@RequestParam Map<String, String> parameters, @RequestParam String templateID, @RequestParam String deliveryChannel) {
return service.previewDocument(parameters, templateID, deliveryChannel);
}
在我的前端,我有这个
this.postPreviewDocument = function(parameters, templateID, deliveryChannel) {
var data = {
parameters: parameters,
templateID: templateID,
deliveryChannel: deliveryChannel
}
console.log(data);
return $http.post(baseURL + "/previewDocument", data, {withCredentials: false, headers:{"Pragma":"no-cache"},responseType: 'arraybuffer'});
};
但是我在后端说一个错误
2019-02-22 10:19:41.487警告18264 --- [nio-8083-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver:已解决 [org.springframework.web.bind.MissingServletRequestParameterException: 必需的字符串参数'templateID'不存在]
如何发布带有参数和其他必需参数的Map?