GWT 历史代币重写
我想做历史令牌重写。不知道可能与否。 例如,如果我的应用程序 URL 是 http://localhost:8080/myapp/#login 其中包含 '登录'作为历史令牌。是否可以重写 URL,如 http://localhost:8080/myapp/user/login。
或者是否可以从历史标记中删除“#”?
I want to do history token rewriting. Don't know its possible or not.
e.g. If my application URL is http://localhost:8080/myapp/#login which contain 'login' as history token. Is it possible to rewrite the URL like http://localhost:8080/myapp/user/login.
Or is it possible to remove '#' from history token?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
#
标记在 URL 中具有特殊含义。浏览器将#
标记之前的所有内容解释为要加载的页面,将#
之后的所有内容解释为页面上的附加信息。这意味着,如果#
标记后的 URL 发生某些更改,则不会重新加载网页,但会创建浏览器历史记录项。 GWT 使用它来创建新的历史记录项,而不重新加载页面。如果您将 URL 从
#login
重写为/user/login
,您将指示浏览器重新加载页面,这意味着重新加载整个 GWT 页面以及所有状态信息已重置。这可能不是您想要的。所以简短的答案是,尽管这在技术上是可行的,但它会将行为从一页网站更改为每次历史记录更改时都会重新加载的多页面网站,而这可能不是您想要的。
The
#
token has special meaning in an URL. The browser interprets everything before the#
token as the page to load, and everything after the#
as additional information for on the page. This means if something is changed in the URL after the#
token, the webpage is not reloaded, but it does create a browser history item. GWT uses this to create new history items, while not reloading the page.If you would rewrite the URL from
#login
to/user/login
you would instruct the browser to reload the page, which means the whole GWT page is reloaded and all state information is reset. This is probably not what you want.So the short answer is, although it's technically possible, it will change the behavior from a one page website to a multi-page website that reloads every time the history changes, and that's probably not something you want.