我正在尝试使用 ExternalTextResource 异步获取大型 html 文件:
public interface MyHtmlResources extends ClientBundle {
public static final MyHtmlResources INSTANCE = GWT.create(MyHtmlResources.class);
@Source("some.html")
public ExternalTextResource getSomeHtml();
}
MyHtmlResources.INSTANCE.getSomeHtml().getText(new ResourceCallback<TextResource>() {
public void onError(ResourceException e) { Window.alert(e.toString()); }
public void onSuccess(TextResource r) {
html.setHTML(r.getText());
}
});
在 Firefox 上,onError 方法总是运行并显示一条消息:
eval() returned null
在 Chrome 上我得到 Uncaught RangeError: Maximum call stack size exceeded
.你知道有没有办法处理大文件?我是否受限于每个浏览器的最大调用堆栈大小?
谢谢。
我的“解决方案”是使用 RequestBuilder,如 italo 发布的问题中所述。
最佳答案
似乎 GET 解析文件内容并且当文件很大时它在某些浏览器中失败。看看这个问题:http://code.google.com/p/google-web-toolkit/issues/detail?id=6248
关于带有大文件的 GWT ExternalTextResource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14105209/