vaadin 中的 getProtocol()
getProtocol() in vaadin
有没有办法在 Vaadin 中获取协议(http 或 https)?我可以得到主机和端口,但我还需要协议。
import com.vaadin.ui.UI;
[...]
UI.getCurrent().getPage().getLocation().getHost();
UI.getCurrent().getPage().getLocation().getPort();
所以我需要这样的东西:
UI.getCurrent().getPage().getLocation().getProtocol();
你已经差不多了:-)
System.out.println("Scheme=[" + Page.getCurrent().getLocation().getScheme() + "]");
Scheme=[http]
根据下面与 Andre 的讨论添加更多选项:
public class MyVaadinUI extends UI {
protected void init(VaadinRequest request) {
System.out.println("Location scheme=[" + Page.getCurrent().getLocation().getScheme() + "]");
System.out.println("Web browser isSecureConnection=[" + Page.getCurrent().getWebBrowser().isSecureConnection() + "]");
System.out.println("Request isSecure=[" + request.isSecure()+"]");
}
}
Location scheme=[http]
Web browser isSecureConnection=[false]
Request isSecure=[false]
有没有办法在 Vaadin 中获取协议(http 或 https)?我可以得到主机和端口,但我还需要协议。
import com.vaadin.ui.UI;
[...]
UI.getCurrent().getPage().getLocation().getHost();
UI.getCurrent().getPage().getLocation().getPort();
所以我需要这样的东西:
UI.getCurrent().getPage().getLocation().getProtocol();
你已经差不多了:-)
System.out.println("Scheme=[" + Page.getCurrent().getLocation().getScheme() + "]");
Scheme=[http]
根据下面与 Andre 的讨论添加更多选项:
public class MyVaadinUI extends UI {
protected void init(VaadinRequest request) {
System.out.println("Location scheme=[" + Page.getCurrent().getLocation().getScheme() + "]");
System.out.println("Web browser isSecureConnection=[" + Page.getCurrent().getWebBrowser().isSecureConnection() + "]");
System.out.println("Request isSecure=[" + request.isSecure()+"]");
}
}
Location scheme=[http]
Web browser isSecureConnection=[false]
Request isSecure=[false]