HTMLエンティティと、商標や著作権記号などの奇妙な文字の両方を含む文字列をJavaのBasicNameValuePairの値に渡そうとしています。実行しようとすると、今は静かに失敗します。コード:
HttpPost httpPost = new HttpPost("http://localhost:8983");
String test = "<field name=\"description\">Example®<ul><li> This is a bunch of stuff I would like to post</li></ul></field>
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("stream.body", test)); // HERE is the string
nvps.add(new BasicNameValuePair("commit","true"));
try {
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
HttpResponse response;
try {
response = httpClient.execute(httpPost);
} catch (IOException ex) {
ex.printStackTrace();
}
"& 記号は、おそらく URL が個別に処理する必要があるクエリ文字であるため、問題を引き起こしていると思います。URL でこのタイプの文字列を実行するにはどうすればよいですか?