
java模拟post 提交multipart/form-data
请求页面:post参数:try {
请求页面:
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryzM0nS9GIodjxCMih
post参数:
------WebKitFormBoundaryzM0nS9GIodjxCMih
Content-Disposition: form-data; name="csrfmiddlewaretoken"
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
try {
reqEntity.addPart("csrfmiddlewaretoken", new StringBody("XXX"));
reqEntity.addPart("input_text", new StringBody("XXX"));
reqEntity.addPart("output_text", new StringBody(""));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
postRequest.setEntity(reqEntity);
HttpResponse response;
response = httpClient.execute(postRequest)
更多推荐
所有评论(0)