GWT:检查URL是否已经死了 [英] GWT: Check if URL is dead

查看:118
本文介绍了GWT:检查URL是否已经死了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图检查url(以字符串形式)是否返回404错误。然而,我似乎无法使用java.net.URL,并且我读了某处,GWT中不支持java.net?如果是这样,我该如何检查GWT中URL是否死亡?



非常感谢。

解决方案

你说得对。在客户端GWT中,您不能使用java.net.URL。查看 Google的JRE仿真参考资料,如果您不确定哪些部分是Java标准库可以与GWT一起使用。 理论上,可以通过AJAX请求来检查URL(请参阅 )。 /javadoc/latest/com/google/gwt/http/client/RequestBuilder.htmlrel =nofollow> RequestBuilder )。但是由于同源策略,浏览器可能会阻止这种尝试。



所以我认为你应该在你的应用程序服务器端实现检查(根据上面Roflcoptr在注释中提供的链接),并用 GWT-RPC


I'm trying to check if a url (in String form) returns 404 error. However, I can't seem to use java.net.URL, and I read somewhere that java.net is not supported in GWT? If so, how do I check if URL is dead or not in GWT?

Much appreciated.

解决方案

You are right. In client side GWT you cannot use java.net.URL. Take a look at Google's JRE Emulation Reference if you are unsure what parts of the Java standard library can be uses with GWT.

Theoretically it would be possible to check a URL with an AJAX request (see RequestBuilder). But due to the same origin policy it is likely that the browser prevents such an attempt.

So I think you should implement the check on your applications server side (according to the link provided by Roflcoptr above in the comments) and call that routine with GWT-RPC.

这篇关于GWT:检查URL是否已经死了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆