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] &l T;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 "/> &NBSP;&NBS P [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] &nbsP;<beans:bean class= "Org.springframework.mobile.device.site.SitePreferenceWebArgumentResolver"/> [html] </argument-resolvers> [html] </annotation-driven>
Introdution to Spring Mobile