在Vaadin中提取URL

时间:2016-11-17 03:11:45

标签: java url hyperlink vaadin

我目前正在使用:

String url = Page.getCurrent().getLocation().toString();

url的地址栏中获取vaadin app。但问题是该应用程序已从www.mywebsite.freehost.com重定向到www.mywebsite.com,而我正在使用的代码正在获取wrong url。它正在获得old url

  

我需要重定向的网址。   我该怎么做?有谁知道吗?

编辑:我在openshift上托管我的Vaadin应用程序,在不同的Web主机上托管我的html网站。我正在将vaadin应用程序重定向到login.mywebsite.com。但是我没有获取URL login.mywebsite.com,而是获取了openshift提供的URL。我该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

此代码将在浏览器地址栏中为您提供服务器名称。

  String url = ((VaadinServletRequest) VaadinService.getCurrentRequest()).getServerName();

答案 1 :(得分:0)

尝试一下:

public class HorizontalCollectionViewLayout : UICollectionViewFlowLayout { [YOUR CLASS] }

(字符串中的请求网址)

HttpServletRequest httpServletRequest = ((VaadinServletRequest)VaadinService.getCurrentRequest()).getHttpServletRequest();