2011-02-15 30 views
0

我的grails应用程序提供了一个动作,应该为jwt数据提供一个gwt客户端。 如果我所说的行动从我的GWT浏览器中得到这个错误:来自gwt的呼叫动作 - >访问控制 - 允许来源不允许的网址

XMLHttpRequest cannot load http://localhost:8080/myApp/myDomain/myAction/123. 
Origin http://127.0.0.1:8888 is not allowed by Access-Control-Allow-Origin. 

这个错误是什么意思?我该如何解决这个问题?

GWT代码:

String url = "http://localhost:8080/myApp/myDomain/myAction/123" 

RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url); 

builder.sendRequest("", new RequestCallback() { 

    @Override 
    public void onResponseReceived(Request request, Response response) { 
     GWT.log("Response: "+response.getText()); 
    } 

    @Override 
    public void onError(Request request, Throwable exception) { 
     GWT.log("ERROR: " + exception.getMessage()); 
    } 
}); 

Grails的代码(动作):

def myAction = { 
    def data = ... 
    render(contentType:"text/json"){data} 
} 

回答

1

您正在尝试进行不同的域名请求。根据“Access-Control-Allow-Origin”,您只能在原始域中执行请求。

相关问题