mobile还有人用吗 spring_spring-mobile

Spring Mobile is an extension to the popular Spring Web MVC web framework that aims to simplify the development of mobile web applications.

Spring Mobile 提供了对 Spring MVC 的扩展,用于帮助开发跨平台的移动Web应用。

文档地址 : http://docs.spring.io/spring-mobile/docs/current/reference/htmlsingle/

spring-mobile功能

--客户端设备识别:识别结果只有3种类型:NORMAL(非手机设备)、MOBILE(手机设备)、TABLET(平板电脑)。在系统里可以通过以下代码获取设备识别结果:

Device currentDevice = DeviceUtils.getCurrentDevice(servletRequest);

--网站偏好设置:Spring 通过设备识别的结果来设置当前网站是NORMAL还是MOBILE。

最后 Spring Mobile会将信息同时放入cookie和request attribute里面。

-- 网站自动切换:可根据不同的访问设备切换到对应的页面

maven 配置

org.springframework.mobile

spring-mobile-device

1.1.3.RELEASE

使用方式

@Controller

public class HomeController {

private static final Logger logger =

LoggerFactory.getLogger(HomeController.class);

@RequestMapping("/")

public void home(Device device) {

if (device.isMobile()) {

logger.info("Hello mobile user!");

} else if (device.isTablet()) {

logger.info("Hello tablet user!");

} else {

logger.info("Hello desktop user!");

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值