2

我想知道是否有人可以提供帮助。我正在开发一个 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);

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

这个链接表明我应该能够像这样向 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

我不太确定这意味着什么。有什么想法吗?

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

干杯,内森

4

1 回答 1

1

浏览了 github 存储库,看看我是否能看出发生了什么:看起来 WURFL 支持由于许可异常而被故意删除

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

这个页面暗示了一个单独的项目,它将提供 WURFL 支持:我还没有找到它。

于 2012-11-15T22:37:00.343 回答