我试图打的Liferay注销的servlet“C /门/注销”通过Java,但它总是返回400响应:Liferay的注销返回400响应
private void sendPost() throws Exception {
String url = "localhost:8080/c/portal/logout";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
// add header
post.setHeader("User-Agent", USER_AGENT);
HttpResponse response = client.execute(post);
System.out.println("\nSending 'POST' request to URL : " + url);
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());
}
你尝试“GET”,而不是“POST”? –
嗨,我已经尝试了GET和POST都没有好像工作 – ravicandy1234
我已经试过你的代码稍微修改没有'USER_AGENT'和'url =“http:// localhost:8080/c/portal/logout”'和' HttpGet'-我收到一个'HTTP/1.1 200 OK'。所以有一些东西在你身边。你可以添加'response.getStatusLine()'的结果吗? –