GWT获取应用程序的路径 [英] GWT getting path of the application

查看:65
本文介绍了GWT获取应用程序的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GWT应用程序,当我在运行应用程序后部署本地主页时是localhost:8888 / myapp.html,但是当我们将它部署到服务器时,在运行其主页的应用程序是107.20.239.198:8080/myapp/ myapp.html。



现在所有相关的路径我的应用程序都失败了。我需要确切路径的地方,我无法得到。现在路径不同。例如,当我在我的应用程序中点击一个特定的窗口小部件 - >它重定向到路径'/#+'地方no.1+地方no.2'
<但现在它在部署在服务器上时会失败,因为它需要路径 - >'/ myapp /#+'place no.1+place no.2'。



所以我怎样才能使它通用,以便我可以处理这两个条件。



任何人都可以帮我解决这个问题吗?



PS我希望我能够很好地表达我的问题,否则您可以发表评论,以便我可以更好地解释它。

你上面提到的你的本地url,看起来你正在 AppEngine 的服务器上运行它。你最好先在你的本地部署你的应用程序到 Tomcat 上。并确保一切工作正常。这些是您在应用程序启动时可以用来获取相对/绝对URL 的几种方法。

  GWT.getHostPageBaseURL(); GWT.getModuleBaseURL(); GWT.getModuleName(); 

希望它有帮助。


I have a GWT application which when I deploy locally homepage after running the application is localhost:8888/myapp.html but when we deploy it to the server, after the application running its homepage is 107.20.239.198:8080/myapp/myapp.html.

Now all the relating paths my application fail. Places where I require the exact path, I cant get that. As now the path is different. For example when I click in a particular widget in my application -> It redirects to the path '/# + "place no.1" + "place no.2" '

But now it fails when deployed on the server as now it requires the path -> '/myapp/# + "place no.1" + "place no.2" '.

So how can I make it generic, so that I can handle both the conditions.

Can anyone help me with this ?

P.S. I hope I am able to express my problem well, else you can comment it so that I can explain it better.

解决方案

From your local url as you mentioned above, it looks like you are running it on AppEngine's server. Better you deploy your application on Tomcat first on your local. And make sure everything is working fine. These are the few methods which you can use to get the relative/absolute urls when your application starts up.

GWT.getHostPageBaseURL(); GWT.getModuleBaseURL(); GWT.getModuleName();

Hope it helps.

这篇关于GWT获取应用程序的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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