如何获取运行我的Vaadin webapp的应用服务器的协议,IP和端口?我正在使用Vaadin 7.
在vaadin 6中我这样做,但不能在vaadin 7中工作:
String server = ((WebApplicationContext) this.getContext()).getHttpSession().getServletContext().getServerInfo();
java.net.URL url = this.getURL();
String s = url.getHost()+":"+url.getPort()+url.getPath();
Run Code Online (Sandbox Code Playgroud)
小智 14
System.out.println(UI.getCurrent().getPage().getLocation().getHost());
System.out.println(UI.getCurrent().getPage().getLocation().getPath());
System.out.println(UI.getCurrent().getPage().getLocation().getPort());
Run Code Online (Sandbox Code Playgroud)
小智 7
我是这样做的:
String basePath = Page.getCurrent().getLocation().getScheme() + ":" +
Page.getCurrent().getLocation().getSchemeSpecificPart()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6732 次 |
最近记录: |