我试图让我的应用程序检测移动设备并呈现该页面,但我没有得到任何响应,但我的 index.html 页面正在呈现。它完全忽略了我的移动控制器。
@Controller
public class DeviceDetection {
@RequestMapping("/")
public @ResponseBody String detectDevice(Device device) {
if (device.isNormal()) {
System.out.println("Inside isNormal()");
return "index";
} else if (device.isMobile()) {
System.out.println("Inside isMobile()");
return "mobilePage";
} else if (device.isTablet()) {
return "mobilePage";
}
return "index";
}
}
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mobile</artifactId>
</dependency>