如何集成Spring Webflow,Spring Mobile和WURFL

时间:2012-09-23 19:46:20

标签: spring-webflow-2 wurfl spring-mobile

我想知道是否有人可以提供帮助。我正在开发一个Spring Webflow 2应用程序,我还希望将Spring Mobile 1.0与WURFL 1.4.2集成。

我让Webflow和Spring Mobile一起工作:

<bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="order" value="1"/>
    <property name="mappings">
        <value>/fnol=flowController</value>
    </property>
    <property name="interceptors">
        <list>
            <bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor" />
        </list>
    </property>

然后在我的一个动作类中,我可以这样做:

public Event startUp(RequestContext arg0) throws Exception {
    // get the http request form the webflow RequestContext
    ServletExternalContext externalContext = (ServletExternalContext) arg0.getExternalContext();
    HttpServletRequest request = (HttpServletRequest) externalContext.getNativeRequest();
    // get the Spring Mobile Device
    Device currentDevice = DeviceUtils.getCurrentDevice(request);

这似乎工作正常,但现在我想在Spring Mobile中使用WURFL,以便我获得一个更丰富的对象来代表客户端功能。

This link建议我应该能够像这样在DeviceResolverHandlerInterceptor中添加一个构造函数:

<bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="order" value="1"/>
    <property name="mappings">
        <value>/fnol=flowController</value>
    </property>
    <property name="interceptors">
        <list>
            <bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor">
                <constructor-arg>
                    <device:wurfl-device-resolver root-location="/WEB-INF/wurfl/wurfl.zip" />
                </constructor-arg>
            </bean>
        </list>
    </property>

我将设备名称空间定义为:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:webflow="http://www.springframework.org/schema/webflow-config"
    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/context
                        http://www.springframework.org/schema/context/spring-context-3.0.xsd
                        http://www.springframework.org/schema/webflow-config
                        http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
                        http://www.springframework.org/schema/mobile/device 
                        http://www.springframework.org/schema/mobile/device/spring-mobile-device-1.0.xsd" >

就我的IDE而言(Eclipse)它很高兴,并且它部署到wtp没问题。但是当我启动wtp时,我收到以下错误:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/mobile/device]
Offending resource: class path resource [fnol-webContext.xml]
Bean 'handlerMapping'
-> Property 'interceptors'
    -> Bean ''
        -> Constructor-arg

我不确定这意味着什么。任何人的想法?

感谢你们提供的任何帮助,

干杯,内森

1 个答案:

答案 0 :(得分:1)

看看github回购,看看我是否能看出发生了什么:看起来因为许可异常而故意删除了WURFL支持

https://github.com/SpringSource/spring-mobile/commit/ca81c6c20f1a9e524b0150e14dab20b020676e0b

此页面提到了一个可以提供WURFL支持的单独项目:我没有找到它。