首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在Spring中解析Multipart/mixed

在Spring中解析Multipart/mixed
EN

Stack Overflow用户
提问于 2017-05-18 08:31:03
回答 2查看 757关注 0票数 3

我想在我的RestController中像下面这样解析请求

代码语言:javascript
复制
POST http://#.#.#.#:#/report HTTP/1.1
User-Agent: Android
Accept: text/html,application/xml,application/json,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: multipart/mixed; boundary=%&REPORT_DIVIDER&%
Authorization: Basic ***
Content-Length: 23236
Host: #.#.#.#:#
Connection: Keep-Alive
Accept-Encoding: gzip


--%&REPORT_DIVIDER&%
Content-Type: application/json

{"content-excluded":true}
--%&REPORT_DIVIDER&%
Content-Disposition: attachment; filename="INSTALLATION"

Content-Type: application/octet-stream
609903cf-fcc0-460c-87db-958e031ac156
--%&REPORT_DIVIDER&%--

此消息符合rfc1341,但我找不到在Spring中解析此消息的方法。

请注意,文件数量可能会有所不同。

我已经尝试过使用CommonsMultipartResolverStandardServletMultipartResolver,但它们都只支持multipart/form-data (rfc1867)。

除了编写我自己的解析器之外,还有什么方法可以在Spring中解析这些请求呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-01-24 10:36:29

虽然这不是一个很好的解决方案,但它是我发现的唯一一个:

实际上,我用this class重新实现了ServletFileUpload,然后用CommonsMultipartResolverthis simple subclass将它加载到apache库中。

票数 0
EN

Stack Overflow用户

发布于 2019-11-25 20:30:17

代码语言:javascript
复制
    @Path("api")
    @PUT
    @Consumes("multipart/mixed")
    @Produces("multipart/mixed")
    public MultiPart twelve( MultiPart multiPart) throws IOException {

    List<BodyPart> bodyParts = multiPart.getBodyParts();
    BodyPartEntity bpe = (BodyPartEntity) bodyParts.get(1).getEntity();
}

这是为基于泽西的春季启动项目。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44036769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档