PR for spring-mobile (#1062)

* rest with spark java

* 4
This commit is contained in:
Abhinab Kanrar
2017-01-29 21:02:38 +05:30
committed by maibin
parent 1e74f9dbe8
commit d4c1ce44b6
8 changed files with 153 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package com.baeldung.controller;
import java.util.logging.Logger;
import org.springframework.mobile.device.Device;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class IndexController {
private final static Logger LOGGER = Logger.getLogger(IndexController.class.getName());
@GetMapping("/")
public String greeting(Device device) {
String deviceType = "browser";
String platform = "browser";
if (device.isNormal()) {
deviceType = "browser";
} else if (device.isMobile()) {
deviceType = "mobile";
} else if (device.isTablet()) {
deviceType = "tablet";
}
platform = device.getDevicePlatform().name();
if (platform.equalsIgnoreCase("UNKNOWN")) {
platform = "browser";
}
LOGGER.info("Client Device Type: " + deviceType +", Platform: " + platform);
return "index";
}
}