模拟表单提交
来源:互联网 发布:silverlight5 for mac 编辑:程序博客网 时间:2024/05/20 21:48
httpclient模拟表单提交
- 创建httpclient对象,相当于创建浏览器。
CloseableHttpClient client = HttpClients.createDefault();
创建请求方法,这里以post方法为例。
HttpPost httpPost = new HttpPost("http://localhost:8080/csdn/admin/login")
设置表单提交的相关参数。
List<NameValuePair> list = new ArrayList<NameValuePair>(); list.add(new BasicNameValuePair("username", "json")); list.add(new BasicNameValuePair("password", "123"));
创建表单实体,设置字符编码等。
UrlEncodedFormEntity uyrlEntity = new UrlEncodedFormEntity(list, "utf-8");
设置请求实体(是这样讲吗),执行请求并处理response对象。
httpPost.setEntity(uyrlEntity); CloseableHttpResponse response = client.execute(httpPost); HttpEntity entity1 = response.getEntity(); InputStream io1 =entity1.getContent(); InputStreamReader isReader1 = new InputStreamReader(io1, "utf-8"); BufferedReader bfReader1 = new BufferedReader(isReader1); String string1 = "",str1; while((str1=bfReader1.readLine())!=null){ string1+=str1; } System.out.println(string1);
0 0
- PHP模拟表单提交
- VC++ 模拟表单提交
- HttpClient4模拟表单提交
- httpClient 模拟表单提交
- 模拟post表单提交
- 模拟表单提交
- nodejs模拟表单提交
- 模拟表单提交的例子
- winform模拟post提交表单
- java代码 模拟表单提交
- 用python模拟提交表单
- delphi webbrowser 模拟表单提交
- JS 模拟动态表单提交
- Java 模拟form表单提交
- C#模拟POST提交表单
- Java模拟Form表单提交
- js 模拟form 表单提交
- Java(servlet)模拟表单提交
- 初识springboot
- ARM内核全解析,从ARM7,ARM9到Cortex-A7,A8,A9,A12,A15到Cortex-A53,A57
- ArrayList的equals()方法解析
- Parallels Desktop虚拟的Centos系统设置静态IP连网
- MySQL下“Can’t create/write to file xxx (Errcode: 13)”错误的解决方法
- 模拟表单提交
- Android之定时刷新数据
- shell 教程六:函数的使用
- iOS开发 判断当前APP版本和升级
- zcmu1781
- 移动端页面开发
- 微信企业号 出现redirect_uri unauthorized 50001 解决办法
- Centos6.6设置中文输入法
- 【APP设计利器】Sketch 41 Mac中文破解版(含汉化插件)