android - getjson 响应在 phonegap 中返回 null (android)

标签 android json jquery-mobile cordova android-emulator

$.getJSON("http://localhost:8080/v1/message", 

  function(data) {
    console.log(data);
      alert("message"+data);//this alert stmt is displayed it means that 
              the service call is getting executed 
    });

服务方式

@RequestMapping(method = RequestMethod.GET,
        value = "/message" )
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public String message()
{
    return "jasdknsd";

 }

我收到此调用的响应为 null 如果我在服务方法中做错了,请帮助我,并且我将它们都放在同一网络中,因为我没有使用回调

最佳答案

不支持连接到本地主机。

http://code.google.com/p/android/issues/detail?id=133

127.0.0.1 是模拟系统自己的环回接口(interface),而不是运行的接口(interface) 您的主机开发机器。

在Android系统中,应该使用10.0.2.2,这是一个专门的别名 设置联系你的主机 127.0.0.1

关于android - getjson 响应在 phonegap 中返回 null (android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9723450/

相关文章:

javascript - 使用关联键更新 JSON 值

安卓admob权限

android - 远程服务在主进程绑定(bind)时被杀死

java - 如何在android中放大位图的触摸点?

python - 没有文字的 JSON 字符串解析器

JQuery Mobile 对话框未打开

android - ImageView 自动链接

javascript - 通过替换常用字符串来压缩 JSON?

jquery-mobile - 页面加载时的 jQuery Mobile 对话框

jquery 移动更改复选框颜色