使用spring mobile识别pc、手机还是平板
pom中加入
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
web.xml中
<filter>
<filter-name>deviceResolverRequestFilter</filter-name>
<filter-class>org.springframework.mobile.device.DeviceResolverRequestFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>deviceResolverRequestFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
然后在你的代码了就可以
Device device=DeviceUtils.getCurrentDevice(request);
String userdisply=device.isMobile()?"mobile":device.isTablet()?"tablet":"pc";