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

时间:2012-03-15 15:56:59

标签: 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请帮助我,如果我在服务方法中做错了,我将它们都放在同一个网络中因为我没有使用回调

2 个答案:

答案 0 :(得分:3)

不支持与localhost的连接。

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

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

在Android系统中,应该使用10.0.2.2,这是一个别名 设置与您的主人127.0.0.1

联系

答案 1 :(得分:1)

使用10.0.2.2代替localhost:8080

相关问题