本文整理汇总了Java中com.vaadin.server.VaadinServletService.getCurrentServletRequest方法的典型用法代码示例。如果您正苦于以下问题:Java VaadinServletService.getCurrentServletRequest方法的具体用法?Java VaadinServletService.getCurrentServletRequest怎么用?Java VaadinServletService.getCurrentServletRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.server.VaadinServletService
的用法示例。
在下文中一共展示了VaadinServletService.getCurrentServletRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDeviceInfo
import com.vaadin.server.VaadinServletService; //导入方法依赖的package包/类
@Nullable
@Override
public DeviceInfo getDeviceInfo() {
// per request cache
HttpServletRequest currentServletRequest = VaadinServletService.getCurrentServletRequest();
if (currentServletRequest == null) {
return null;
}
DeviceInfo deviceInfo = (DeviceInfo) currentServletRequest.getAttribute(DeviceInfoProvider.NAME);
if (deviceInfo != null) {
return deviceInfo;
}
Page page = Page.getCurrent();
if (page == null) {
return null;
}
WebBrowser webBrowser = page.getWebBrowser();
DeviceInfo di = new DeviceInfo();
di.setAddress(webBrowser.getAddress());
di.setBrowserApplication(webBrowser.getBrowserApplication());
di.setBrowserMajorVersion(webBrowser.getBrowserMajorVersion());
di.setBrowserMinorVersion(webBrowser.getBrowserMinorVersion());
di.setChrome(webBrowser.isChrome());
di.setChromeFrame(webBrowser.isChromeFrame());
di.setChromeFrameCapable(webBrowser.isChromeFrameCapable());
di.setEdge(webBrowser.isEdge());
di.setFirefox(webBrowser.isFirefox());
di.setOpera(webBrowser.isOpera());
di.setIE(webBrowser.isIE());
if (webBrowser.isWindows()) {
di.setOperatingSystem(OperatingSystem.WINDOWS);
} else if (webBrowser.isAndroid()) {
di.setOperatingSystem(OperatingSystem.ANDROID);
} else if (webBrowser.isIOS()) {
di.setOperatingSystem(OperatingSystem.IOS);
} else if (webBrowser.isMacOSX()) {
di.setOperatingSystem(OperatingSystem.MACOSX);
} else if (webBrowser.isLinux()) {
di.setOperatingSystem(OperatingSystem.LINUX);
}
di.setIPad(webBrowser.isIPad());
di.setIPhone(webBrowser.isIPhone());
di.setWindowsPhone(webBrowser.isWindowsPhone());
di.setSecureConnection(webBrowser.isSecureConnection());
di.setLocale(webBrowser.getLocale());
di.setScreenHeight(webBrowser.getScreenHeight());
di.setScreenWidth(webBrowser.getScreenWidth());
currentServletRequest.setAttribute(DeviceInfoProvider.NAME, di);
return di;
}
示例2: getHttpServletRequest
import com.vaadin.server.VaadinServletService; //导入方法依赖的package包/类
/**
*
* @deprecated use VaadinServletService.getCurrentServletRequest()
*/
@Deprecated
public HttpServletRequest getHttpServletRequest() {
return VaadinServletService.getCurrentServletRequest();
}
示例3: getServer
import com.vaadin.server.VaadinServletService; //导入方法依赖的package包/类
private static String getServer() {
HttpServletRequest request = VaadinServletService.getCurrentServletRequest();
return (request.isSecure() ? "https://" : "http://") + request.getServerName();
}