此股票交易下单股票交易下单接口api,接口api,股票交易下单接口api,接口调用与被调用,都是在springMVC框架下使用参数以json格式传输。
//我们调用别人的股票交易下单股票交易下单接口api,接口api,股票交易下单接口api,接口
public boolean IUseOthers(String name,String gender){
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod('http://111..111.11.11:8080/---');//写网址
postMethod.setRequestHeader('Content-type','application/x-www-form-urlencoded;charset=utf-8');
try{
postMethod.addParameter('name',name);
postMethod.addParameter('gender',gender);
int status = client.executeMethod(postMethod);
//获取返回信息
JSONObject jsonObject = JSONObject.fromObject(postMethod.getResponBodyAsString().toString);
String code = jsonObject.getString('code');
boolean flag = false;
if('999'.equals(code)){
flag =true;
}
}catch(HttpException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally{
if(postMehod!=null){
postMehod.releaseConnection();
}
}
return flag;
}
}
文章为作者独立观点,不代表观点