我試圖訪問內部站點的項目,這是網頁的源文件,爲現場如何利用點擊一個URLConnection的按鈕(編程)
<form method="post" action="doDelete">
Are you sure you want to delete 'Apple?'?
<input name="Submit" value="Yes" class="submit-button" type="submit" />
</form>
我有這樣的代碼
的一部分doSubmit(「http://ma.some-website:8080/member/ Apple/delete」,「是」);
public static void doSubmit(String url, String data) throws Exception {
String content = "";
URL siteUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) siteUrl.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);
HttpURLConnection.setFollowRedirects(true);
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
content = URLEncoder.encode(data, "UTF-8");
System.out.println(content);
out.writeBytes(content);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = "";
while((line=in.readLine())!=null) {
System.out.println(line);
}
in.close();
}
在網頁會出現一個確認框,詢問「我要刪除此用戶(蘋果)」如何編程點擊?我在想我需要確定「doDelete」的方法並傳入「是」參數?
這是Java/JSP嗎? – BoltClock 2012-03-05 21:06:50
它現在在Java應用程序,但是當它運行時,我將在我的項目中加入一個jsp – 2012-03-05 21:12:31