我正在尝试登录 .jsf 内网页面,这是其中的一部分:
<form method="POST" action="j_security_check" name="loginForm" id="loginForm">
<input name="j_username" type="text" class="textbox" maxlength="30"/>
<input name="j_password" type="password" class="textbox" maxlength="30"/>
<input type=submit value="Enter" class="button">
<input type=submit value="Exit" class="button">
</form>
我在java中搜索并尝试过类似的东西,但没有奏效,我得到与结果相同的页面:
HttpPost post = new HttpPost("http://xxxx/login.jsf");
List <NameValuePair> parameters = new ArrayList <NameValuePair>();
parameters.add(new BasicNameValuePair("j_username", "92232776"));
parameters.add(new BasicNameValuePair("j_password", "(7110oi14)"));
UrlEncodedFormEntity sendentity;
sendentity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
post.setEntity(sendentity);
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(post, httpContext);
System.out.print(convertInputStreamToString(response.getEntity().getContent()));
(我正在使用 httpcomponents-client-4.2)
我需要做什么才能登录此页面?我需要对代码按钮“发送”做些什么吗?
谢谢你们。