/*
* 请求PHP接口 //请求方法
* @param pathUrl 接口地址
* @param params 请求参数
* @return httpUrlConnection
*/
public String httpUrlConnection(String pathUrl, String userName,String userPwd) {
try {
// 建立连接
URL url = new URL(pathUrl);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
// //设置连接属性
httpConn.setDoOutput(true);// 使用 URL 连接进行输出
httpConn.setDoInput(true);// 使用 URL 连接进行输入
httpConn.setUseCaches(false);// 忽略缓存
httpConn.setRequestMethod("POST");// 设置URL请求方法
String requestString = "userName=" + userName;
String requestString1 = "userPwd=" + userPwd;
// 设置请求属性
// 获得数据字节数据,请求数据流的编码,必须和下面服务器端处理请求流的编码一致
byte[] requestStringBytes = requestString.get
ssm(java)调用thinkphp接口
最新推荐文章于 2024-06-01 18:21:09 发布