Introdution to Spring Mobile

1. In Eclipse, create a new Maven Project using the spring-mvc-jpa-archetype.

2. Add the spring-mobile-device dependency to pom.xml.

[html] view plaincopy

<dependency>

<groupId>org.springframework.mobile</groupId>

<artifactId>spring-mobile-device</artifactId>

<version>1.0.0.RELEASE</version>

[html]

</dependency>

3. Add the following Spring Mobile interceptors in servlet-context.xml

[html]

<interceptors>

[html]

<!-- Resolve the device that originated the web request -->

[html] view plaincopy

<beans:bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor" />

[html]

<!-- Manage the user‘s site preference -->

[html]

<beans:bean class="org.springframework.mobile.device.site.SitePreferenceHandlerInterceptor" />

[html]

<!-- Redirects mobile users to domain.com/quickspringmobile/spring/m/ -->

[html]

<beans:bean class="org.springframework.mobile.device.switcher.SiteSwitcherHandlerInterceptor" factory-method="urlPath">         <beans:constructor-arg value="/m" />

[html]

<beans:constructor-arg value="/quickspringmobile/spring" />

[html]

</beans:bean>

[html]

</interceptors>

4. The resolved device is available under the currentDevice request attribute. The site preference is available under the currentSitePreference request attribute.

[html]  www.2cto.com

<annotation-driven>

[html]

<argument-resolvers>

[html]

<beans:bean class="org.springframework.mobile.device.DeviceWebArgumentResolver" />

[html]

<beans:bean class="org.springframework.mobile.device.site.SitePreferenceWebArgumentResolver" />

[html]

</argument-resolvers>

[html]

</annotation-driven>

时间: 2024-10-18 23:07:35

Introdution to Spring Mobile的相关文章

160606、springmvc中使用Spring Mobile

springmobile特点: 1.客户端设备识别:识别结果只有3种类型:NORMAL(非手机设备).MOBILE(手机设备).TABLET(平板电脑). 2.网站偏好设置:Spring 通过设备识别的结果来设置当前网站是NORMAL还是MOBILE.最后 Spring Mobile会将信息同时放入cookie和request attribute里面. 3.网站自动切换:可根据不同的访问设备切换到对应的页面 使用(基于maven项目) 第一步:pom.xml <dependencies>  

Spring:探测访问网站的设备类型

[该教程翻译自Spring官方,并进行适当删减.] 你将搭建的 创建一个Spring MVC项目,来探测访问网站的设备类型(手机.电脑.平板),并动态切换呈现的视图. 工具 一个文本编辑器,JDK1.6及以上,Maven 3.0+或者Gradle 1.11+.(本文将使用Maven) pom.xml清单: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven

玩转spring boot——properties配置

前言 在以往的java开发中,程序员最怕大量的配置,是因为配置一多就不好统一管理,经常出现找不到配置的情况.而项目中,从开发测试环境到生产环境,往往需要切换不同的配置,如测试数据库连接换成生产数据库连接,若有一处配错或遗漏,就会带来不可挽回的损失.正因为这样,spring boot给出了非常理想的解决方案——application.properties.见application-properties的官方文档:http://docs.spring.io/spring-boot/docs/curr

大概解释下spring的模块和生态圈都有哪儿些

Spring框架是一个轻量级的企业级开发的一站式解决方案.所谓解决方案就是可以基于spring解决JAVAEE开发的所有问题.Spring框架主要提供了IOC容器.AOP.数据访问.WEB开发.消息.测试等相关技术的支持. Spring使用简单的POJO(Plainold java object,即无任何限制的普通java对象)来进行企业级开发.每一个spring管理的java对象都称之为bean:而spring提供了一个IOC容器用来初始化对象,解决对象间的依赖管理和对象的使用. 可参考的网站

【译文】用Spring Cloud和Docker搭建微服务平台

by Kenny Bastani Sunday, July 12, 2015 转自:http://www.kennybastani.com/2015/07/spring-cloud-docker-microservices.html This blog series will introduce you to some of the foundational concepts of building a microservice-based platform using Spring Cloud

Spring Framework Ecosystem – Introduction to Spring Projects

来自于:http://springtutorials.com/spring-ecosystem/ Hello and Welcome to Spring Tutorials Blog! Is it fair to assume you have at least heard of Spring Framework official website – spring.io? If not, I would recommend that you check it out. There are som

spring boot项目配置文件集合

# =================================================================== # COMMON SPRING BOOT PROPERTIES # # This sample file is provided as a guideline. Do NOT copy it in its # entirety to your own application. ^^^ # ===================================

Spring In Action 4 学习笔记(一)Spring概览

Spring的核心概念就是DI和AOP,是Spring实现所有复杂华丽框架的基石. 相对于EJB等重型框架,Spring更加轻量化,可以强化普通的POJO对象. 1.简化JAVA开发 为了尽可能简化Java的开发,Spring遵循如下4个策略: Lightweight and minimally invasive development with POJOs 使用POJO类进行轻量化低侵入式的开发 Loose coupling through DI and interface orientati

Spring boot配置文件application.properties

# =================================================================== # COMMON SPRING BOOT PROPERTIES # # This sample file is provided as a guideline. Do NOT copy it in its # entirety to your own application.               ^^^ # =====================