1
I Problem habe den Aufbau eine api, deren Antwort ist mehrteiliger/Form-Daten mit application/json InhaltFederauflage eines Web Service zurückkehrt multipart/Form-Daten mit application/json content-type
Beispiel:
http://localhost:8080/getData
sollte
--HaRZrgSMRFElYDqkcBMfTMp3BUMHKQAtP
Content-Disposition: form-data; name="response"
Content-Type: application/json
[{"name":"xyz"}]
--HaRZrgSMRFElYDqkcBMfTMp3BUMHKQAtP--
der aktuelle Code-Schnipsel Rückkehr ist
@RequestMapping(value="/getData", method=RequestMethod.GET,
produces=MediaType.MULTIPART_FORM_DATA_VALUE)
public MultipartFile getMultipartAsFileAsObject() throws Exception {
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("sample.json").getFile());
String readFile = readFile("sample.json");
DiskFileItem fileItem = new DiskFileItem("file", "application/json", false, "response", (int) file.length() , file);
fileItem.getOutputStream();
MultipartFile multipartFile = new CommonsMultipartFile(fileItem);
return multipartFile;
}
und die Antwort, die ich bekomme, ist {} ein leeres Json-Objekt. kann jemand lassen Sie mich wissen, wo ich falsch werde