码迷,mamicode.com
首页 > 编程语言 > 详细

Introdution to Spring Mobile

时间:2014-09-22 18:05:52      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   div   sp   art   cti   on   c   

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>  

Introdution to Spring Mobile

标签:http   io   ar   div   sp   art   cti   on   c   

原文地址:http://www.cnblogs.com/atomgame/p/3986226.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!