简体   繁体   English

使用GWT屏蔽浏览器URL

[英]Mask browser URL with GWT

My GWT app URL when a page is access looks like this: 访问页面时,我的GWT应用URL如下所示:

http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997#ViewPage;hash=6a

or 要么

http://127.0.0.1:8888/index.html#ViewPage;hash=6a

However, this does not look good, is there a way for the GWT client side code to make it look like this, to "mask" it somehow to: 但是,这看起来不太好,GWT客户端代码是否有办法使它看起来像这样,以某种方式“屏蔽”它以:

http://127.0.0.1:8888/6a

Where I have a servlet configured to forward this "shortened" URL to the long URL above so its very safe to make the URL "masked"? 我在哪里配置了一个servlet来将该“缩短的” URL转发到上面的长URL,从而非常安全地使URL“被屏蔽”? Without losing state and history. 不会丢失状态和历史。

I don't see any way to do this directly with GWT, since GWT needs access to the code fragment in the URL to manage browsing history and state. 我看不到有任何直接用GWT执行此操作的方法,因为GWT需要访问URL中的代码片段来管理浏览历史和状态。

One indirect way to do it would be to embed your GWT module inside an iframe that occupies the whole page area. 一种间接的方法是将GWT模块嵌入到占据整个页面区域的iframe中。 The drawback is that the user would loose the ability to bookmark pages inside the GWT application. 缺点是用户将无法在GWT应用程序中为页面添加书签。

By the way, I don't share your view that it "does not look good". 顺便说一句,我不同意您的看法,即“看起来不太好”。 Many popular Web applications use the URL like this, including Gmail. 许多流行的Web应用程序都使用此类URL,包括Gmail。 Most users don't care about what's in the URL. 大多数用户不关心URL中的内容。

The shortest possibility I know would be an URL like: 我知道的最短的可能性将是这样的URL

http://127.0.0.1:8888/#6a

Therefore you must configure index.html as default page. 因此,您必须将index.html配置为默认页面。 (It must be configured as default response). (必须将其配置为默认响应)。

You also have to rewrite the history-management. 您还必须重写历史记录管理。 You have to remove the Place-Token from the URL . 您必须从URL删除Place-Token。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM