Android Framework(III)Spring-mobile and wurfl with Groovy Controller
Android Framework(III)Spring-mobile and wurfl with Groovy Controller 1. backgroup Get the spring-mobile source codes >git clone --recursive git://github.com/SpringSource/spring-mobile.git spring-mobile Get the wurfl files wurfl zip file: http://sourceforge.net/projects/wurfl/files/WURFL/ wurfl patch file: http://wurfl.sourceforge.net/web_browsers_patch.xml 2. enable the jar files repository add 3 more respositories to my ivysettings.xml: add some jar files configuration to ivy.xml: 3. Spring configuration changes I changed my core-context.xml to add wurfl and spring mobile part. UTF-8 UTF-8 text/html;charset=UTF-8 I deal with wurfl in my groovy controller, and I add the velocity resolver to my controller. Here comes the wurfl-context.xml: Some settings in spring configuration file is in properties, config.properties: ########################################## # wurfl configuration ########################################## wurfl.zip.file=/home/luohua/work/easymarket/conf/wurfl/wurfl-2.0.28.zip wurfl.patch.file=/home/luohua/work/easymarket/conf/wurfl/web_browsers_patch.xml ################################################ # velocity path ################################################ velocity.file.path=file://home/luohua/work/easymarket 4. The Groovy Controller package com.sillycat.easymarket.controller; import org.springframework.stereotype.Controller; import org.springframework.mobile.device.site.SitePreference; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @Controller public class HomeController { @RequestMapping("/home") public ModelAndView home(SitePreference sitePreference) { ModelAndView view = null; if (sitePreference == SitePreference.MOBILE) { println sitePreference.isMobile(); println "home-mobile"; view = new ModelAndView("home_mobile"); } else { println sitePreference.isMobile(); println "home"; view = new ModelAndView("home"); } return view; } } And the view of page home.vm: #set($layout = "layout/layout.vm")
Device Information
Your browser:
- ${currentDevice.userAgent}
is capable of:
- ${currentDevice.capabilities}
and has a preferred markup grade of:
- ${currentDevice.markUp}
references: http://www.springsource.org/spring-mobile http://static.springsource.org/spring-mobile/docs/1.0.x/reference/htmlsingle/ http://www.abdn.ac.uk/~csc228/teaching/CS5302/practicals/practical_spring_wurfl.shtml http://hi.baidu.com/hn_why/blog/item/442a171ab3ee3ce41ad57696.html