GWT - 发出GET请求

Chr*_*ris 11 gwt

简单的问题.我需要在GWT中发出重定向到新页面的GET请求,但我找不到合适的API.

有吗?我应该自己简单地形成URL然后做Window.Location.replace

(原因是我希望我的搜索页面可以链接)

谢谢.

(抱歉没有让我的问题清楚,最初)

Sil*_*rom 13

看看 http://library.igcar.gov.in/readit2007/tutori/tools/gwt-windows-1.4.10/doc/html/com.google.gwt.http.client.html

public class GetExample implements EntryPoint {

    public static final int STATUS_CODE_OK = 200;

    public static void doGet(String url) {
        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

        try {
            Request response = builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable exception) {
                    // Code omitted for clarity
                }

                public void onResponseReceived(Request request, Response response) {
                    // Code omitted for clarity
                }
            });

        } catch (RequestException e) {
            // Code omitted for clarity
        }
    }

    public void onModuleLoad() {
        doGet("/");
    }
}
Run Code Online (Sandbox Code Playgroud)


Chr*_*ris 2

重定向到新页面是通过 Window.Location.replace 完成的。

应使用历史机制来处理多个页面。