![](/img/trans.png)
[英]Parsing Multipart/Mixed with Multipart/Alternative body in java
[英]Parsing Multipart/mixed in Spring
我想在我的RestController
解析如下請求
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 中解析它的方法。
請注意,文件數量可能會有所不同。
我已經嘗試過使用CommonsMultipartResolver
或StandardServletMultipartResolver
,但都只支持multipart/form-data
( rfc1867 )。
除了編寫自己的解析器之外,還有什么方法可以在 Spring 中解析這些請求嗎?
@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();
}
這是基於球衣的彈簧靴項目。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.