- 浏览: 2490516 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Android Framework(III)Spring-mobile and wurfl with Groovy Controller
- 博客分类:
- Summary
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:
<url name="office4">
<artifact pattern="http://maven.springframework.org/snapshot/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
<url name="office5">
<artifact pattern="http://maven.springframework.org/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
<url name="office6">
<artifact pattern="http://maven.springframework.org/milestone/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
add some jar files configuration to ivy.xml:
<!-- spring device -->
<dependency org="org/springframework/mobile" name="spring-mobile-device" rev="1.0.0.M3" />
<!-- wurlf -->
<dependency org="net/sourceforge/wurfl" name="wurfl" rev="1.2.2" />
<!-- velocity -->
<dependency org="org/apache/velocity" name="velocity" rev="1.7" />
<dependency org="org/apache/velocity" name="velocity-tools" rev="2.0" />
3. Spring configuration changes
I changed my core-context.xml to add wurfl and spring mobile part.
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<list>
<ref bean="deviceResolverHandlerInteceptor"/>
<ref bean="sitePreferenceHandlerInterceptor" />
</list>
</property>
</bean>
<bean id="handlerAdapter" class="com.sillycat.easygroovyplugin.servlet.proxy.ProxyAwareAnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonConverter" />
</list>
</property>
<property name="customArgumentResolvers">
<list>
<ref bean="deviceWebArgumentResolver" />
<ref bean="sitePreferenceWebArgumentResolver" />
</list>
</property>
</bean>
<bean id="velocityConfig"
class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="${velocity.file.path}/template/" />
<property name="velocityProperties">
<props>
<prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop>
<prop key="contentType">text/html;charset=UTF-8</prop>
</props>
</property>
</bean>
<bean id="velocityViewResolver"
class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
<property name="layoutUrl" value="layout/layout.vm"/>
<property name="cache" value="false" />
<property name="suffix" value=".vm" />
<property name="exposeSpringMacroHelpers" value="true" />
<property name="contentType" value="text/html;charset=UTF-8" />
</bean>
I deal with wurfl in my groovy controller, and I add the velocity resolver to my controller.
Here comes the wurfl-context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:device="http://www.springframework.org/schema/mobile/device"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mobile/device
http://www.springframework.org/schema/mobile/device/spring-mobile-device-1.0.xsd
">
<bean id="deviceWebArgumentResolver" class="org.springframework.mobile.device.DeviceWebArgumentResolver" />
<bean id="sitePreferenceWebArgumentResolver" class="org.springframework.mobile.device.site.SitePreferenceWebArgumentResolver" />
<bean id="sitePreferenceHandlerInterceptor" class="org.springframework.mobile.device.site.SitePreferenceHandlerInterceptor" />
<bean id="deviceResolverHandlerInteceptor" class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor">
<constructor-arg>
<device:wurfl-device-resolver root-location="file:${wurfl.zip.file}"
patch-locations="file:${wurfl.patch.file}" />
</constructor-arg>
</bean>
</beans>
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")
<h3>Device Information</h3>
<p>Your browser:</p>
<ul>
<li>${currentDevice.userAgent}</li>
</ul>
<p>is capable of:</p>
<ul>
${currentDevice.capabilities}
</ul>
<p>and has a preferred markup grade of:</p>
<ul>
<li>${currentDevice.markUp}</li>
</ul>
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
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:
<url name="office4">
<artifact pattern="http://maven.springframework.org/snapshot/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
<url name="office5">
<artifact pattern="http://maven.springframework.org/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
<url name="office6">
<artifact pattern="http://maven.springframework.org/milestone/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
add some jar files configuration to ivy.xml:
<!-- spring device -->
<dependency org="org/springframework/mobile" name="spring-mobile-device" rev="1.0.0.M3" />
<!-- wurlf -->
<dependency org="net/sourceforge/wurfl" name="wurfl" rev="1.2.2" />
<!-- velocity -->
<dependency org="org/apache/velocity" name="velocity" rev="1.7" />
<dependency org="org/apache/velocity" name="velocity-tools" rev="2.0" />
3. Spring configuration changes
I changed my core-context.xml to add wurfl and spring mobile part.
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<list>
<ref bean="deviceResolverHandlerInteceptor"/>
<ref bean="sitePreferenceHandlerInterceptor" />
</list>
</property>
</bean>
<bean id="handlerAdapter" class="com.sillycat.easygroovyplugin.servlet.proxy.ProxyAwareAnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonConverter" />
</list>
</property>
<property name="customArgumentResolvers">
<list>
<ref bean="deviceWebArgumentResolver" />
<ref bean="sitePreferenceWebArgumentResolver" />
</list>
</property>
</bean>
<bean id="velocityConfig"
class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="${velocity.file.path}/template/" />
<property name="velocityProperties">
<props>
<prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop>
<prop key="contentType">text/html;charset=UTF-8</prop>
</props>
</property>
</bean>
<bean id="velocityViewResolver"
class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
<property name="layoutUrl" value="layout/layout.vm"/>
<property name="cache" value="false" />
<property name="suffix" value=".vm" />
<property name="exposeSpringMacroHelpers" value="true" />
<property name="contentType" value="text/html;charset=UTF-8" />
</bean>
I deal with wurfl in my groovy controller, and I add the velocity resolver to my controller.
Here comes the wurfl-context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:device="http://www.springframework.org/schema/mobile/device"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mobile/device
http://www.springframework.org/schema/mobile/device/spring-mobile-device-1.0.xsd
">
<bean id="deviceWebArgumentResolver" class="org.springframework.mobile.device.DeviceWebArgumentResolver" />
<bean id="sitePreferenceWebArgumentResolver" class="org.springframework.mobile.device.site.SitePreferenceWebArgumentResolver" />
<bean id="sitePreferenceHandlerInterceptor" class="org.springframework.mobile.device.site.SitePreferenceHandlerInterceptor" />
<bean id="deviceResolverHandlerInteceptor" class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor">
<constructor-arg>
<device:wurfl-device-resolver root-location="file:${wurfl.zip.file}"
patch-locations="file:${wurfl.patch.file}" />
</constructor-arg>
</bean>
</beans>
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")
<h3>Device Information</h3>
<p>Your browser:</p>
<ul>
<li>${currentDevice.userAgent}</li>
</ul>
<p>is capable of:</p>
<ul>
${currentDevice.capabilities}
</ul>
<p>and has a preferred markup grade of:</p>
<ul>
<li>${currentDevice.markUp}</li>
</ul>
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
发表评论
-
Stop Update Here
2020-04-28 09:00 268I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 434NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 316Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 326Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 297Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 383Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 379Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 332Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 403VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 339Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 420NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 365Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 294Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 214GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 395GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 281GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 268Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 268Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 255Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 241Serverless with NodeJS and Tenc ...
相关推荐
SMIL, Voxeo's Prophecy server, VoiceXML (VXML), grXML, Frost library, WALL, WURFL, SMS, MMS, mobile payment gateways, mobile widgets, Mobile AJAX, Android, Google Gears, and Dojo Offline. What you ...
WURFL is a set of proprietary application programming interfaces (APIs) and an XML configuration file which contains information about device capabilities and features for a variety of mobile devices...
Use the latest development techniques—including Responsive Web Design and server-side device detection with WURFL Learn quickly through images, puzzles, stories, and quizzes We think your time is too...
2016-05-23 由官方scientiamobile更新的php api
Tera-WURFL可以使用PHP,MySQL数据库后端和标准化的无线通用资源文件(WURFL)来识别移动设备的功能。
com.scientiamobile wurfl-core 1.8.0.0 浏览器检测 jar包
详细的浏览器版本检测,功能库强大,api易懂。wurfl,浏览器版本检测的不二选择
所有移动终端类型都在这个官方的文件中了,了解最新动态,请电邮联系
详细的浏览器版本检测,功能库强大,api易懂。wurfl,浏览器版本检测的不二选择
NULL 博文链接:https://crazysky.iteye.com/blog/1179069
工具(C)将WURFL XML移动浏览器数据库拆分为带有符号链接(NTFS存根)的单个设备文件,以减少访问时间和服务器负载。 包括一个简单PHP库/ API作为如何访问数据的示例,以及一个示例phtml文件。
移动Web的使用在呈爆炸式增长。很快,人们会更愿意在手机和平板电脑而不是PC机上浏览网页。...使用*的开发技术,包括响应式Web设计,以及利用WURFL完成服务器端设备检测;通过图片、谜题、故事和问答轻松学习。
用于.NET(C#)的WURFL API。 该API设计专注于WURFL的发展,包括用于数据访问抽象层的模块和用于UAgent进行启发式搜索的模块。
Java Swing GUI,用于查看,搜索和编辑WURFL移动设备信息。
Dinfo 是一个独立的 Java servlet,带有可用的 WAR 包,用于提供对 WURFL 信息的访问。
Apache Mobile Filter是检测移动设备的最简单,最快的方法。 AMF是一套工具,可以直接从Apache访问设备存储库(例如WURFL,DetectRight,51Degrees.mobi或免费的AMF服务):现在,无论您使用哪种语言,您都可以检测...
它是WURFL或DeviceAtlas的绝佳替代品。 在Maven上也可用。 1)下载zip并解压缩。 2)将位于“ dist”目录中的核心JAR添加到您的Java项目中。 3)导入以下软件包:import fiftyone.mobile.detection.Match; 导入五十...
深度学习锥束计算机断层扫描 该存储库为Tensorflow提供了锥束反投影的实现。 它可用于数据驱动的投影领域... @article { wurfl2018deep , title = { Deep learning computed tomography: Learning projection-domain
也许不如WURFL准确,但它的处理速度快且小。 无需运行复杂的后端脚本,您可以通过将客户端重定向到适当的端点(位置,上游,主机)来节省时间和资源(套接字,CPU)。 要求 您需要与LUA模块一起运行的Nginx: 安装...