我正在使用Spring Boot,并编写了以下代码来上传文件:
@POST
@Path("/uploadMultipleFiles")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@ResponseBody
public void uploadMultipleFiles(@RequestParam("files") MultipartFile[] files) {
Arrays.asList(files);
}
HTML:
<div id="upload-file-div">
<div class="upload-div-labels">
<span>
<coral-icon icon="upload " size="L" style="color: gray"></coral-icon>
</span>
<span><label class="file-drop-label">Drop here to upload</label></span>
<span><label>or</label></span>
<span>
<button is="coral-button" class="upload-file-display-button">Select file(s)</button>
<!-- Change to .js, .css-->
<input type="file" name="files" accept="*" multiple style="display: none"/>
</span>
</div>
但是,我遇到以下错误:
Caused by: org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: ` not found for media type=multipart/form-data;boundary=----WebKitFormBoundaryA806c7bZP7X7vl3j, type=class [Lorg.springframework.web.multipart.MultipartFile;, genericType=class [Lorg.springframework.web.multipart.MultipartFile;.
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:231)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
at com.adobe.asr.jersey.intercepter.AsrJerseyReaderIntercepter.aroundReadFrom(AsrJerseyReaderIntercepter.java:41)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundReadFrom(MappableExceptionWrapperInterceptor.java:74)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1085)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:874)
at org.glassfish.jersey.server.ContainerRequest.readEntity(ContainerRequest.java:271)
at org.glassfish.jersey.server.internal.inject.EntityParamValueFactoryProvider$EntityValueFactory.provide(EntityParamValueFactoryProvider.java:96)
at org.glassfish.jersey.server.spi.internal.ParamValueFactoryWithSource.provide(ParamValueFactoryWithSource.java:71)
at org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:94)
在大多数SO职位上,主要原因是MultiPartFile.class
没有注册,但我已经注册了。
任何指向该怎么做的指针?