Java 응용 프로그램을 사용하여 html 형식으로 POST하려고합니다. 즉 다음과 같이 폼을 잡고, (. 예를 들어 http://www.domain.tld/somepage.html)을 중요한 경우 형식은 확장자가 html, 페이지에 :Java 응용 프로그램의 HTTP POST
<Form method="POST">
<input type="hidden" name="op" value="checkfiles">
<Textarea name="list" rows=12 style="width:100%;font:12px Arial"></Textarea>
<br><input type="submit" name="process" value="Check">
</Form>
내가 아파치 HTTPComponents로했지만, 지금까지 내 시도가 실패되었습니다. 어떤 이유
private static void submit(String text) throws Exception{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.domain.tld/somepage.html");
List <NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("list", text));
httppost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
HttpResponse response = httpclient.execute(httppost);
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString());
}
이 http://www.domain.tld/에서 나에게 페이지를 반환 : 여기 내가 사용하는 기능입니다. 도와주세요.
추가 params.add (새 BasicNameValuePair ("op", "checkfiles"))); 이제는 작동합니다. 고맙습니다! – nmpg