带有JSON的Spring MVC分段请求

我想使用Spring MVC发布带有一些JSON数据的文件。因此,我开发了一种休息服务


@RequestMapping(value = "/servicegenerator/wsdl", method = RequestMethod.POST,consumes = { "multipart/mixed", "multipart/form-data" })

@ResponseBody

public String generateWSDLService(@RequestPart("meta-data") WSDLInfo wsdlInfo,@RequestPart("file") MultipartFile file) throws WSDLException, IOException,

        JAXBException, ParserConfigurationException, SAXException, TransformerException {

    return handleWSDL(wsdlInfo,file);

}

当我从其他客户端发送请求时  content-Type = multipart/form-data or multipart/mixed,出现下一个异常: org.springframework.web.multipart.support.MissingServletRequestPartException


谁能帮助我解决这个问题?


我可以@RequestPart同时将Multipart和JSON发送到服务器吗?


胡子哥哥
浏览 574回答 3
3回答

红颜莎娜

如文档所述:在找不到以其名称标识的“ multipart / form-data”请求的一部分时引发。这可能是因为该请求不是多部分/表单数据,或者是因为该部分不存在于请求中,或者是因为未正确配置Web应用程序以处理多部分请求-例如,没有MultipartResolver。
打开App,查看更多内容
随时随地看视频慕课网APP