2

来自 GWT(使用 RestyGWT)的典型 restful 调用如下所示:

LoginService.Util.getService().login("FACEBOOK", new MethodCallback<Void>() {
    @Override
    public void onSuccess(Method method, Void response) {

    }

    @Override
    public void onFailure(Method method, Throwable exception) {

    }
});

尽管调用可能会响应 onSuccess,但不会处理重定向响应。服务器端重定向如下所示:

return Response.seeOther(new URI(url)).build(); 

处理通过RequestBuilder或发出的请求重定向的正确方法是什么RestyGWT

4

2 回答 2

1

尝试这个,

response.sendRedirect("http://10.62.229.57:8080/birt/");

我用于Jax-rs Web 服务中的重定向响应

于 2015-12-23T04:36:54.777 回答
1

检查本教程RequestBuilder,然后试试这个,

// Send request to server and catch any errors.
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

try {
    Request request = builder.sendRequest(null, new RequestCallback() {
        public void onError(Request request, Throwable exception) {
            displayError("Couldn't retrieve JSON");
        }

        public void onResponseReceived(Request request, Response response) {
            if (200 == response.getStatusCode()) {
                updateTable(JsonUtils.safeEval(response.getText()));
            } else {
                displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
            }
        }
    });
} catch (RequestException e) {
    displayError("Couldn't retrieve JSON");
}
于 2015-12-23T04:58:29.520 回答