Apache HttpComponents POST提交带参数提交
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();
}
}
}
Apache HttpComponents POST提交带参数提交的更多相关文章
- ajaxFileUpload带参数提交(亲测可用)
使用ajaxFileUpload上传文件时,有时需要带参数提交,网上有很多资料说使用data,但其实要使用data带参数是需要修改的,否则后台是获取不到的. 分析原因: ajaxFileUpload为 ...
- DataTables手动带参数提交至服务器
一:参数传递及接收 JavaScript: 黄背景部分为参数传递关键 <script type="text/javascript"> var table; var de ...
- ngResource提交json数据如何带参数
ngResource提交json数据如何带参数 直接使用ngResource和REST服务接口交互可以让程序显得简洁,前提是配置好跨域和OPTIONS请求的支持,与此同时,如果需要带些额外的参数,有两 ...
- 论httpclient上传带参数【commons-httpclient和apache httpclient区别】
需要做一个httpclient上传,然后啪啪啪网上找资料 1.首先以前系统中用到的了commons-httpclient上传,找了资料后一顿乱改,然后测试 PostMethod filePost = ...
- SpringMVC控制器接收不了PUT提交的参数的解决方案
摘要: SpringMVC控制器接收不了PUT提交的参数的解决方案 这次改造了下框架,把控制器的API全部REST化,不做不知道,SpringMVC的REST有各种坑让你去跳,顺利绕过它们花了我不少时 ...
- C# 模拟提交带附件(input type=file)的表单
今天调用某API时,对于文档中的传入参数:File[] 类型,感觉很陌生,无从下手! 按通常的方式在json参数中加入file的二进制数据提交,一直报错(参数错误)!后来经过多方咨询,是要换一种 表单 ...
- struts2获取前台提交的参数
CreateTime--2017年8月25日16:30:11 Author:Marydon struts2对获取前台提交参数的封装 需要导入: import java.util.Enumerati ...
- mvc ajax提交数组参数(转)
http://blog.csdn.net/lonestar555/article/details/10192595/ 在action中的参数以数组方式接收数据 一.表单方式 1.提交Form < ...
- 用HttpWebRequest提交带验证码的网站
using System; using System.Drawing; using System.IO; using System.Net; using System.Text; using Syst ...
随机推荐
- HDUOJ---The Moving Points
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- 【LeetCode】44. Wildcard Matching (2 solutions)
Wildcard Matching Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any ...
- UltraEdit打开中文乱码
http://hellofs.blog.51cto.com/6109153/1187548 UltraEdit很强大,但是今天发现在打开含有中文的文本时会乱码,还是在配置里找找相关的设置,可以在如图的 ...
- 关于域名如何指向WordPress homepage问题的解决
http://genuinelx.org/oldversion.php/archives/19为解决这个问题真的费了我半天的时间= = ,不写出来真的难以抒发苦闷. 下午VPS开通了,虽然有个ip被墙 ...
- windows服务器开启openssl
windows服务器默认是没有开启openss的php扩展支持,不过一般服务器里面默认都已经安装了这个功能.自己开启一下就好,今天在安装某程序的时候,需要用到openss的支持,才发现windows服 ...
- 修改jQuery.validate验证方法和提示信息
1.添加验证方法 在jquery.validate.js文件中直接添加验证方法,例如: jQuery.validator.addMethod("Specialstring", fu ...
- PopupWindow的简单使用(结合RecyclerView)
Android弹窗: 在Android中弹出式菜单(以下称弹窗)是使用十分广泛一种菜单呈现的方式,弹窗为用户交互提供了便利.关于弹窗的实现大致有以下两种方式AlertDialog和PopupWindo ...
- Linux时间子系统(十二) periodic tick
一.tick device概念介绍 1.数据结构 在内核中,使用struct tick_device来抽象系统中的tick设备,如下: struct tick_device { struct ...
- 取出分组后每组的第一条记录(不用group by)按时间排序
--操作日志表 CREATE TABLE [dbo].[JobLog]( [JobLogId] [int] IDENTITY(1,1) NOT NULL, [FunctionId] [nvarchar ...
- struts2 页面标签或ognl表达式取值--未完待续
一.加#号取值和不加#号取值的解说 1.s:property 标签——value属性使用事项 1)涉及问题:取值时什么时候该加#,什么时候不加? 2)介绍 <s:property value=& ...