package com.js.ai.modules.pointwall.interfac;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List; import org.activiti.engine.impl.util.json.JSONObject;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
/**
*
* @ClassName: TestLogin
* @Description: TODO 客戶端模拟登录
* @author:
* @date:
*/
public class TestLogin {
public String login(String userName,String password){
CloseableHttpClient httpclient = HttpClients.createDefault();
String url = "http://27.155.64.173:8687/pointwall/a/client/login";
HttpPost httpPost = new HttpPost(url);
//建立HttpPost对象
List<NameValuePair> params=new ArrayList<NameValuePair>();
JSONObject jsonObject = new JSONObject();
jsonObject.put("loginName", userName);//用户名
jsonObject.put("password", password);//密码
//建立一个NameValuePair数组,用于存储欲传送的参数
params.add(new BasicNameValuePair("userInfo",jsonObject.toString()));
try {
httpPost.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
CloseableHttpResponse response = httpclient.execute(httpPost);
HttpEntity entity = response.getEntity();
//打印目标网站输出内容
String responseHtmQueryPage = IOUtils.toString(entity.getContent());// 获取相应的网页内容
System.out.println(responseHtmQueryPage+"=====");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null; }
public static void main(String[] args) {
TestLogin testRegister = new TestLogin();
testRegister.login("150****8552", "admin");
}
}

  

最新文章

  1. Tools - Get technical information from the Internet
  2. 第二章平稳时间序列模型——ACF和PACF和样本ACF/PACF
  3. oracle 监测数据库是否存在指定字段
  4. PHP中的function函数详解
  5. [转] When exactly does the virtual table pointer (in C++) gets set for an object?
  6. Javascript Duff装置 循环展开(Javascript Loop unrolling Duff device)
  7. 字符编码笔记:ASCII,Unicode和UTF-8(转)
  8. 防止SSH自动断线
  9. dubbo基本信息
  10. Python Memo 赋值与ID (Assignment &amp; id())
  11. Rails-Treasure chest2 嵌套表单;
  12. JavaScript中直接量和变量
  13. Python3.6+nginx+uwsgi部署Django程序到阿里云Ubuntu16.04系统
  14. BZOJ 4242 水壶(BFS建图+最小生成树+树上倍增)
  15. 在angular中利用分页插件进行分页
  16. start-stop-daemon 启动停止系统守护进程
  17. Java工具类_表结构自动生成对应的实体类、Mapper.xml文件、Dao类
  18. C#中关于用户名和密码的验证问题。
  19. [计算机网络] DNS劫持和DNS污染
  20. Struts2_day02--课程安排_结果页面配置

热门文章

  1. mysql学习笔记(Centos下rpm编译配置+远程访问)
  2. New Concept English three (32)
  3. Android process 的启动流程
  4. Arcgis Android API开发之离线地图
  5. iOS开发之Documentation.build/Script-BC552B3A15.sh:
  6. 行为驱动开发BDD概要
  7. BZOJ - 3196 Tyvj 1730 二逼平衡树 (线段树套treap)
  8. bzoj 2657 旅游
  9. iOS开发单例模式 dispatch_once
  10. C语言内存对齐对则