javax.ws.rs.ProcessingException:RESTEASY004655:无法调用请求

问题描述 投票:0回答:1

我想,作为一个客户端,张贴一个zip文件到“REST服务”,使用RestEasy的3.0.19。这是代码:

public void postFileMethod(String URL)  {       
         Response response = null;              
         ResteasyClient client = new ResteasyClientBuilder().build();
         ResteasyWebTarget target = client.target(URL); 

         MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();

         FileBody fileBody = new FileBody(new File("C:/sample/sample.zip"), 
ContentType.MULTIPART_FORM_DATA);              

         entityBuilder.addPart("my_file", fileBody);            
         response = target.request().post(Entity.entity(entityBuilder, 
MediaType.MULTIPART_FORM_DATA));            
}   

我得到的错误是这个:

javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request
....
Caused by: javax.ws.rs.ProcessingException: RESTEASY003215: could not 
find writer for content-type multipart/form-data type: 
org.apache.http.entity.mime.MultipartEntityBuilder

我怎么解决这个问题?我看着一些帖子,但代码是从我的略有不同。

感谢大伙们。

java rest jax-rs resteasy
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.