java如何获取url参数 java怎么发送一个http请求?

[更新]
·
·
分类:互联网
2023 阅读

java如何获取url参数

java怎么发送一个http请求?

java怎么发送一个http请求?

publicstaticvoidmain(String[]args)throwsException{URLurlnewURL(

springboot的url地址怎么写?

/依据用户openId判断用户以前是否已登录过,如未登录,则添加到数据库
({}---{}, accessToken, openId);
JSONObject userInfo (accessToken, openId);
//调用后台接口
String checkurlV1/OrgManager/getUsers;
AuthInfo authInfo new AuthInfo(, , , );
String authInfoJson (authInfo);
String queryCase filtername () authInfo authInfoJson pageablefalse pageSize2 pageNum0 sortDescname:desc orgIde9292051-2ede-11e7-8c78-c85b767a1aee;
JSONObject jsonResult (logger,checkurl,queryCase);
if((isOk)true)
{
MapString,JSONArray nickname new HashMapString,JSONArray();
MapString,JSONArray headimgurl new HashMapString,JSONArray();
(nickname,nickname);
(headimgurl,headimgurl);
} else {
String createurl V1/UserManager/createUser;
String UserCase filtername () authInfo authInfoJson pageablefalse pageSize2 pageNum0 sortDescname:desc orgIde9292051-2ede-11e7-8c78-c85b767a1aee;
JSONObject jsonUser (logger,createurl,UserCase);
}
以上就部分代码:这里DubboService是暴露给你的接口;checkurl就是接口文档里面的url;UserCase是查询条件,这是访问数据库的接口认证。如果访问成功将部分参数传给前端,如果访问不成功将得到参数写入数据库
以下是DubboService方法:
package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
/**
* Created by Administrator on 2017/8/10.
*/
public class DubboService {
private static HttpClient client ().build();
public static String serverIphttp://192.168.1.119:8099/;
public static JSONObject invokeService(Logger logger, String uri, String queryCase) {
HttpPost request new HttpPost(serverIp uri);
(queryCase);
StringEntity reqEntity null;
try {
reqEntity new StringEntity(queryCase);
} catch (UnsupportedEncodingException e) {
();
}
(application/x-www-form-urlencoded);
(reqEntity);
JSONObject jsonResultnull;
try {
HttpResponse response client.execute(request);
String strResult (());
jsonResult (strResult);
(result: jsonResult);
} catch (IOException e) {
();
}
return jsonResult;