我想在重定向到某个外部URL时发送几个参数。我试过httpclient方法,他们发布的数据,但不重定向到外部网址。 有什么想法? 这里是我的代码: 尝试{从java后端发布表单并重定向到它
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod("https://paymentsite.com/pay") {
@Override
public boolean getFollowRedirects() {
System.out.println("Overrriding the HttpClient Follow Redirect switch.");
return true;
}
};;
try {
//httpClient
postMethod.addParameter("amt","850");
postMethod.addParameter("pid","155");
httpClient.executeMethod(postMethod);
if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
//now i want the user to be redirected to the external site. with the post parameters...
} else {
}
} catch (Exception e) {
System.out.println("Exception : " + e.toString());
e.printStackTrace();
}
} catch (Exception e) {
System.out.println("exception main: " + e.toString());
e.printStackTrace();
}
所以这意味着后端代码中的任何post方法都无法将其发送到操作页面? – hotplugin 2014-08-31 05:42:36
这是正确的。 – 2014-08-31 06:10:35