我使用java和vaadin
我做了window.getURL(),它返回我,例如- 99.22.22.22:8080/2/然而,它应该返回app.server.com/2/
当然,app.server.com与99.22.22.22:8080相同
但是我怎么才能用app.server.com取代它呢??
发布于 2015-09-16 21:04:56
我猜这就是How to get the Vaadin 7 application server IP and port?的答案。
请尝试以下操作:
System.out.println(UI.getCurrent().getPage().getLocation().getHost());
System.out.println(UI.getCurrent().getPage().getLocation().getPath());
System.out.println(UI.getCurrent().getPage().getLocation().getPort());或通过ip获取主机名:
InetAddress addr = InetAddress.getByName("99.22.22.22");
String host = addr.getHostName();
System.out.println(host);https://stackoverflow.com/questions/32609048
复制相似问题