$.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/