如何实现 GWT 回调 url?
我正在编写一个将使用 OAuth 的 GWT 应用程序。 OAuth 提供了通过您传入的 url 以及作为 url 参数一部分的访问密钥“回调”您的网站的功能。
我的问题是:对于 GWT 应用程序,如何允许将自定义 URL 粘贴/重定向到地址栏?本质上,这将是一个服务器请求,使用带有 jsp 的 tomcat 服务器非常简单,但是有没有办法使用纯 GWT 实现来处理这个问题?
我可以想象以下是可能的:
- 编写一个与 GWT 项目一起部署的 jsp 页面
- 存储访问密钥
- 将用户再次重定向到我的 GWT 应用程序的主页
有没有更纯粹的方法来使用 GWT 执行此操作?我可以直接调用 RPC 服务来执行此任务吗?如果我调用 RPC 服务,我是否应该将用户重定向到主页?我可以只实现 GWT 客户端代码,以便它识别从 url 传递的自定义参数吗?
您认为最好的方法是什么?
I'm writing a GWT application that's going to use OAuth. OAuth provides the ability to 'callback' to your website via a url that you pass into it along with an access key as part of the url parameters.
My question is this: For a GWT application, how can I allow a custom URL to be pasted / redirected into the address bar? Essentially it will be a server request which is dead simple using a tomcat server with jsp, but is there a way to handle this using a pure GWT implementation?
I can imagine the following is posible:
- Write a jsp page that is deployed with the GWT project
- Store the access key
- Redirect the user again to the main page of my GWT application
Is there a more pure way to do this with GWT? Can I call directly into the RPC service to do this task? If I call into the RPC service, am I supposed to redirect the user to a main page? Can I just implement my GWT client side code so it recognizes custom parameters passed from the url?
What do you think is the best approach for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅 com.google.gwt.user.client.Window.Location.replace(String newUrl),但坏消息是您将丢失所有内部历史记录。以下是一个人的OAuth 及其纯 GWT 解决方案的经验的博客文章。另外还有一个执行 OAuth 的 GWT 示例项目。
See com.google.gwt.user.client.Window.Location.replace(String newUrl), however the bad news is that you will lose all internal history. Here is a blog entry of one person's experiences with OAuth and his pure GWT solution. Also there is a GWT example project that does OAuth.
我也遇到过这个问题。这是我的解决方案:
调用 RPC 并且
您无法从 rpc(servlet) 发送重定向。
I have also encountered with this problem. Here is my solution :
call RPC and
You can not send redirect from rpc(servlet).