Apache HttpComponents POST提交带参数提交
Apache 参数 提交 post
2023-09-11 14:16:57 时间
public class Test { public static void main(String[] args) throws IOException { DefaultHttpClient httpclient = new DefaultHttpClient(); try { HttpPost httpost = new HttpPost("http://localhost:8080/task/index.jsp"); List <NameValuePair> nvps = new ArrayList <NameValuePair>(); nvps.add(new BasicNameValuePair("IDToken1", "username")); nvps.add(new BasicNameValuePair("IDToken2", "password")); httpost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); HttpResponse response = httpclient.execute(httpost); HttpEntity entity = response.getEntity(); System.out.println("Login form get: " + response.getStatusLine()); EntityUtils.consume(entity); System.out.println("Post logon cookies:"); List<Cookie> cookies = httpclient.getCookieStore().getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { httpclient.getConnectionManager().shutdown(); } } }
相关文章
- Exception in thread "main" java.io.IOException: Mkdirs failed to create /var/folders/q0/1wg8sw1x0dg08cmm5m59sy8r0000gn/T/hadoop-unjar6090005653875084137/META-INF/license at org.apache.hadoop.util.Run
- 【资料合集】Apache Flink 精选PDF下载
- apache Tomcat 配置账户管理项目
- Apache Velocity开发者指南–导读
- An internal error occurred during: "Launching xxxxxx (1)". basedir G:javaotherapache-maven-3.3.9 does not exist
- 《PHP、MySQL和Apache入门经典(第5版)》一2.5 在Windows上安装MySQL
- Apache 网站日志分析
- 错误处理:java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addFilter
- Nginx何时取代Apache?
- centos环境下apache支持PHP配置的一个Bug
- apache开源项目--Mahout
- apache开源项目--solr
- apache开源项目--Apache Commons Imaging
- phpstorm不安装apache就可以本地测试PHP