有一个使用 GWT Places/Activity 工具的 GWT 应用程序。还有一个 servlet(目前,与 GWT 无关)我需要能够将用户重定向到 GWT 应用程序。有没有办法可以在我的 servlet 中构建地方描述,然后将其转换为 URL 以将用户重定向到?
1 回答
If the GWT app uses generated PlaceHistoryMapper implementation, then you can build an instance of the place on the server-side and pass it to its PlaceTokenizer
's getToken method to get the place-specific token, and append to the tokenizer's prefix, with a colon (:
) as a separator.
Otherwise, use the app's place history handler implementation (provided it can be used on the server) and call getToken.
Once you have the history token, then if the app uses the DefaultHistorian, then simply use the token as the hash of the URL. Otherwise, it'll depend on the app's own historian implementation (for instance, if uses the HTML5 History API, then it probably won't use a #
in the URL).