zoukankan      html  css  js  c++  java
  • httpclient 方式提供接口

    在后台写好自己的方法;

    打开shiro验证,设置url访问;

    提供包调用http方式连接后台获取数据:

    String url = getUrl();
    HttpClient client = new HttpClient();
    PostMethod method = new PostMethod(url);    // 使用 POST 方式提交数据   
    NameValuePair nvp = new NameValuePair("parameter",parameter);
    method.setRequestBody(new NameValuePair[] {nvp});
    client.executeMethod(method);   //打印服务器返回的状态   
     //打印服务器返回的状态  
    System.out.println(method.getStatusLine());  
      //打印返回的信息  
    System.out.println(method.getResponseBodyAsString());
    String result = method.getResponseBodyAsString();

    pom提供依赖:

    <dependency>
    <groupId>commons-httpclient</groupId>
    <artifactId>commons-httpclient</artifactId>
    <version>3.1</version>
    </dependency>
  • 相关阅读:
    Stupid Tower Defense
    Lifting the Stone
    城市地平线
    BestCoder Sequence
    Miaomiao's Geometry
    Rating
    Turn the pokers
    Peter's Hobby
    HTTP关键词收集
    HTTP出现前的协议
  • 原文地址:https://www.cnblogs.com/wsh1230/p/7704299.html
Copyright © 2011-2022 走看看