首页 > 代码库 > Introdution to Spring Mobile
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="http://www.mamicode.com/m" />
[html]
<beans:constructor-arg value="http://www.mamicode.com/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>
Introdution to Spring Mobile
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。