Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php RequestBuilder返回null_Php_Gwt - Fatal编程技术网

Php RequestBuilder返回null

Php RequestBuilder返回null,php,gwt,Php,Gwt,我有以下问题 我创建了一个类来处理对数据库的所有调用。 我正在使用GWT前端的RequestBuilder发送HTTP GET请求 public String getDadosGET(String phpFilePath) { rb = new RequestBuilder(RequestBuilder.GET, phpFilePath); rb.setHeader(header, headerValue); try { response = rb.se

我有以下问题

我创建了一个类来处理对数据库的所有调用。 我正在使用GWT前端的RequestBuilder发送HTTP GET请求

public String getDadosGET(String phpFilePath) {
    rb = new RequestBuilder(RequestBuilder.GET, phpFilePath);
    rb.setHeader(header, headerValue);

    try {
        response = rb.sendRequest(null, new RequestCallback() {

            @Override
            public void onResponseReceived(Request request, Response response) {
                text = response.getText();                  
            }

            @Override
            public void onError(Request request, Throwable exception) {

            }
        });
    } catch (RequestException e) {
        e.printStackTrace();
    }
    return text;
}
现在,如果我在
onResponseReceived
方法中输出文本,它就不是空的。 如果在返回文本之前完成,则为空

我需要的是强制程序首先获取数据,然后返回方法


谢谢。

我想您还没有完全理解异步调用的概念。看看这本书


我不认为有一种同步进行GWT调用的方法,这正是您想要的。

我知道返回文本;第行在text=response.GetText()之前执行;线