最近有个需求,我司和另个公司之间的接口需要进行交互,我们以GET参数 http://xxx.xxx.xxx/xxx?sign=xxxxxxxxxx进行传递信息,我想知道我们传递的时候用java代码在后台如何实现,还有需要我们这边也得有个服务端,需要他们进行访问,该如何实现?

解决方案 »

  1.   

    1.你请求对方,可以使用jdk的URLConnection或者第三方框架okhttp、httpclient等,自己拼装http请求到对方指定的url上
    2.对方请求你,你需要提供一个url地址给他,你自己应用里面写一个处理该url请求的模块,获取到get参数
      

  2.   

    Java 网络编程 之 HTTP Get Post http://www.verejava.com/?id=17002852927681
      

  3.   

    public static String loadJSON(String url) {
            StringBuilder json = new StringBuilder();
            try {
                URL oracle = new URL(url);
                URLConnection yc = oracle.openConnection();
                BufferedReader in = new BufferedReader(new InputStreamReader(
                        yc.getInputStream(),"utf-8"));//防止乱码
                String inputLine = null;
                while ((inputLine = in.readLine()) != null) {
                    json.append(inputLine);
                }
                in.close();
            } catch (MalformedURLException e) {
            } catch (IOException e) {
            }
            return json.toString();
        }
      

  4.   

    https://www.cnblogs.com/mybug/p/9365607.html看下我的
      

  5.   

    如果你不是程序员, 就叫你公司的程序员弄, 一般都会, 如果你是刚接触的程序员,就去百度搜一下java http请求的实例,很多,大部分都可以拿来直接用