Java – multipartentitybuilder sends pictures to the railway server
•
Java
I'm trying to send multiparty builder to my rails server However, when I try to build it, it crashes and gives me errors
03-25 09:44:50.001 W / System. err:java. util. concurrent. ExecutionException:java. Lang. nosuchmethoderror: no static method create (ljava / Lang / string; [lorg / Apache / HTTP / namevaluepair;) Lorg / Apache / HTTP / entity / contenttype; In the class lorg / Apache / HTTP / entity / contenttype; Or its superclass ('org. Apache. Http. Entity. Contenttype ')
HttpPost httpost = new HttpPost(url); multipartentityBuilder entity = new multipartentityBuilder.create(); entity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); for(int index=0; index < nameValuePairs.size(); index++) { ContentBody cb; if(nameValuePairs.get(index).getName().equalsIgnoreCase("File")) { File file = new File(nameValuePairs.get(index).getValue()); FileBody isb = new FileBody(file); entity.addPart(nameValuePairs.get(index).getName(),isb); } else { // Normal string data cb = new StringBody(nameValuePairs.get(index).getValue(),ContentType.TEXT_PLAIN); entity.addPart(nameValuePairs.get(index).getName(),cb); } } return entity.build();
This is the code I'm using. I still encounter errors when building multiparty. It will say errors
Solution
Try using httpmime version 4.3 six
I try to use 4.4, but it's always the same problem
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码