所以我目前正在尝试使用 JsonpRequestBuilder API 来尝试访问远程文件,但是我只是在使用 google 网页链接进行测试,并且遇到了超时异常。不太确定我在这里缺少什么。任何帮助,将不胜感激。
package com.webapp.client;
import java.util.logging.Logger;
import com.webapp.client.ExcelFileJavascriptObject;
import com.google.gwt.jsonp.client.JsonpRequestBuilder;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
public class DataHttpRequest {
private final String url2 = "http://www.google.ca";
private Logger logger = Logger.getLogger("DataRequest.java");
public void retrieveFile() {
JsonpRequestBuilder builder = new JsonpRequestBuilder();
builder.requestObject(url2,
new AsyncCallback<ExcelFileJavascriptObject>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
logger.severe(caught.getMessage());
logger.severe(caught.toString());
}
@Override
public void onSuccess(ExcelFileJavascriptObject result) {
// TODO Auto-generated method stub
Window.alert(result.toString());
}
});
}
public void onModuleLoad() {
retrieveFile();
}
}
package com.webapp.client;
import com.google.gwt.core.client.JavaScriptObject;
public class ExcelFileJavascriptObject extends JavaScriptObject{
protected ExcelFileJavascriptObject(){
}
}