【发布时间】:2012-02-14 20:41:19
【问题描述】:
我已经开发了一个 GWT 应用程序,并且还在 localhost 机器上安装了一个 Apache Solr 服务器。
Solr 工作正常,查询返回所需结果。
现在为了将结果嵌入到我的 GWT 应用程序中,我使用 GWT 的 RequestBuilder 向 Solr 服务器发送一个 http 请求。
查询已到达 Solr,因为我可以在命令提示符中查看它。
在 GWT 端,请求成功,因为我的 onResponseRecieved() 被调用。但是响应的大小是0,状态码也是0。
我找不到问题出在哪里。
此外,如果存在同源策略,则应该运行 onError() 方法,但它不是。
以下是我的发送和处理代码
String url = "http://localhost:8983/solr/select/?q=bname:"+whatBox.getText()+"&version=2.2&start=0&rows=10&indent=on";
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, URL.encode(url));
System.out.println("here");
try{
Request req = rb.sendRequest(null, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
System.out.println("in res");
System.out.println(response.getHeadersAsString());
RootPanel.get("content").clear();
RootPanel.get("content").add(new Label(response.getText()));
}
@Override
public void onError(Request request, Throwable exception) {
// TODO Auto-generated method stub
System.out.println("error");
}
});
}catch(RequestException e){
e.printStackTrace();
}
任何帮助将不胜感激!
【问题讨论】: