Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Spring中解析多部分/混合_Java_Spring_Http_Spring Mvc_Multipart - Fatal编程技术网

Java 在Spring中解析多部分/混合

Java 在Spring中解析多部分/混合,java,spring,http,spring-mvc,multipart,Java,Spring,Http,Spring Mvc,Multipart,我想在我的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=%&

我想在我的
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&%--
这条消息是一致的,但我无法在Spring中找到解析这条消息的方法

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

我已经尝试过使用
commonmultipartresolver
StandardServletMultipartResolver
,但两者都只支持
multipart/formdata
()


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

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

我基本上使用重新实现了
ServletFileUpload
,然后使用
commonmultipartresolver的

@Path(“api”)将其加载到apache库中
    @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();
}
@放 @消耗(“多部分/混合”) @产生(“多部分/混合”) 公共多部分12(MultiPart MultiPart)引发IOException{ 列出bodyParts=multiPart.getBodyParts(); BodyPartEntity bpe=(BodyPartEntity)bodyParts.get(1.getEntity(); }
这是基于泽西岛的spring boot项目