其他分享
首页 > 其他分享> > HTTP接口-跨域-callback

HTTP接口-跨域-callback

作者:互联网

原文链接:http://www.cnblogs.com/tiandi/p/10518781.html

1.客户端和正常调用非跨域接口一样
2.服务端
返回的时候用callback+(返回值)的方式返回结果. callback为客户端的隐藏参数.
public String converJsonResultSimple(String jsonString ,String callback){
if(callback!=null && !"".equals(callback)){
jsonString = callback + "(" + jsonString + ")";
}
return jsonString;
}
@RequestMapping(value = "/uploadUserBehaviorInfo", method = {RequestMethod.GET,RequestMethod.POST})
public String uploadUserBehaviorInfo(String data,String callback){
Sting resutStr = data+"处理结果";
return converJsonResultSimple(resutStr,callback);
}

转载于:https://www.cnblogs.com/tiandi/p/10518781.html

标签:www,jsonString,HTTP,跨域,RequestMethod,resutStr,callback,String
来源: https://blog.csdn.net/weixin_30437481/article/details/98189320