代码之家  ›  专栏  ›  技术社区  ›  Tushar Ahirrao

使用RequestBuilder调用请求时出现问题

gwt
  •  1
  • Tushar Ahirrao  · 技术社区  · 14 年前

    我的密码是

        String url = "http: gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity";
        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL
                .encode(url));
    
    
    
        try {
            Request request = builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable exception) {
                      Couldn't connect to server (could be timeout, SOP
                      violation, etc.)
                }
    
                public void onResponseReceived(Request request,
                        Response response) {
    
                    System.out.println(response.getText() + "Response");
    
                    if (200 == response.getStatusCode()) {
                        Window.alert(response.getText());
                    } else {
                        Window.alert(response.getText());
                    }
                }
            });
        } catch (RequestException e) {
            e.printStackTrace();
        }
    

    com.google.gwt.http.client.RequestPermissionException:URL http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity 无效或违反同一来源安全限制 位于com.google.gwt.http.client.RequestBuilder.doSend(RequestBuilder.java:378) 位于com.google.gwt.http.client.RequestBuilder.sendRequest(RequestBuilder.java:254) 位于com.ip.client.IpAddressTest.onModuleLoad(IpAddressTest.java:46) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 位于java.lang.reflect.Method.invoke(Method.java:597) 位于com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369) 位于com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185) 在com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380) 位于com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) 原因:com.google.gwt.http.client.RequestException:(NS\u ERROR\u DOM\u BAD\u URI):拒绝访问受限制的URI

    2 回复  |  直到 14 年前
        1
  •  0
  •   John    14 年前

    “同源策略”是浏览器为了用户的安全而实现的。如果从一个网站加载javascrip代码,那么该代码将无法开始向其他网站发送请求。它只能向 相同的 代码来自的站点。

    GWT docs .

        2
  •  1
  •   Sajjan Sarkar    11 年前

    我们将GWT用于由Coldfusion服务器提供服务的UI,并开始在托管模式下看到这个错误。

    将IE中受信任站点区域的安全级别更改为中-低,为我修复了此问题。

    enter image description here