RequestBodyと使用RequestEntity

1 HttpClientをクライアント= 新しいHttpClientを();
2 PostMethodポスト= 新しいPostMethod(redirectUrl)。
3          パート[]部分= {
 4                   StringPart( "ユーザ" 、「AAA」)、
 5                  新しい StringPart( "パスワード"、 "BBB" 6                  }。
7          post.setRequestEntity(新しいMultipartRequestEntity(部品、post.getParams()))。
8  client.executeMethod(POST)。
9文字列結果= post.getResponseBodyAsString()。
1 HttpClientをクライアント= 新しいHttpClientを();
2 PostMethodポスト= 新しいPostMethod(redirectUrl)。
3          のNameValuePair []ペア= {
 4              新規のNameValuePair( "ユーザ" 、「AAA」)、
 5                          新規のNameValuePair( "パスワード" 、「BBB」)
 6                          }。
7          post.setRequestBody(対)。
8  client.executeMethod(POST)。
9文字列結果= post.getResponseBodyAsString()。

 

おすすめ

転載: www.cnblogs.com/leavescy/p/11761864.html