Конфигурация Spring WebFlow 2 и Apache Tiles 3. Второй вид не работает.

Я не могу настроить веб-поток с плитками Apache. Первый вид отображается, но второй дает

HTTP Status 404 - Запрашиваемый ресурс недоступен.

SpringMVC-диспетчерская-servlet.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:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:webflow-config="http://www.springframework.org/schema/webflow-config"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
     http://www.springframework.org/schema/webflow-config
 http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.4.xsd">

    <context:component-scan base-package="com.rog.webshop.controller"/>
    <mvc:resources mapping="/resources/**" location="/resources/"/>
    <!--<mvc:default-servlet-handler default-servlet-name="myCustomDefaultServlet"/>-->
    <mvc:annotation-driven conversion-service="conversionService" enable-matrix-variables="true" validator="validator"/>


    <!--TILES -->
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles.xml</value>
            </list>
        </property>
    </bean>

    <bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
                  value="org.springframework.web.servlet.view.tiles3.TilesView">
        </property>
        <property name="order" value="-2"/>
    </bean>







    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
        <property name="validationMessageSource" ref="messageSource"/>
    </bean>

    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="messages"/>
    </bean>

    <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">

        <property name="converters">
            <list>
                <bean id="roleToUserProfile" class="com.rog.webshop.util.RoleToUserProfileConverter"/>
                <bean id="categoryToProduct" class="com.rog.webshop.util.CategoryConverter"/>
            </list>
        </property>
    </bean>


    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="10240000"/>
    </bean>






    <!--WEBFLOW CONFIG-->
    <webflow-config:flow-executor id="flowExecutor"
                                  flow-registry="flowRegistry"/>
    <webflow-config:flow-builder-services id="flowBuilderServices"
                                          validator="validator"
                                          view-factory-creator="mvcViewFactoryCreator"/>
    <webflow-config:flow-registry id="flowRegistry"
                                  base-path="WEB-INF/flows"
                                  flow-builder-services="flowBuilderServices">
        <webflow-config:flow-location path="/checkout/checkout-flow.xml"
                                      id="checkout"/>
    </webflow-config:flow-registry>

    <!-- Configures Web Flow to use Tiles to create views for rendering; Tiles allows for applying consistent layouts to your views -->
    <bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
        <property name="viewResolvers" ref="tilesViewResolver" />
    </bean>
    <bean id="flowHandlerMapping" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property name="flowRegistry" ref="flowRegistry"/>
        <property name="order" value="-1"/>
    </bean>
    <bean id="flowHandlerAdapter" class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor"/>
    </bean>







    <!-- Configure to plugin JSON as request and response in method handler -->
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
        <property name="messageConverters">
            <list>
                <ref bean="jsonMessageConverter"/>
            </list>
        </property>
    </bean>
    <!-- Configure bean to convert JSON to POJO and vice versa -->
    <bean id="jsonMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
    </bean>


</beans>

Мой поток

<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/webflow
                            http://www.springframework.org/schema/webflow/spring-webflow.xsd">

    <var name="order" class="com.rog.webshop.model.order.Order" />

    <action-state id="addCartToOrder">
        <evaluate expression="cartService.validate(requestParameters.cartId)"
                  result="order.cart" />
        <transition to="InvalidCartWarning"
                    on-exception="com.rog.webshop.exception.InvalidCartException" />
        <transition to="collectCustomerInfo" />
    </action-state>

    <view-state id="collectCustomerInfo" view="collectCustomerInfo" model="order">
        <!--<binder>-->
            <!--<binding property="customer.customerId" required="true"  />-->
            <!--<binding property="customer.name" required="true" />-->
            <!--<binding property="customer.billingAddress" required="true" />-->
            <!--<binding property="customer.phoneNumber" required="true" />-->
        <!--</binder>-->
        <transition on="customerInfoCollected" to="collectShippingDetail" />
    </view-state>

    <view-state id="collectShippingDetail"  view="collectShippingDetail" model="order">
        <transition on="shippingDetailCollected" to="orderConfirmation" />
        <transition on="backToCollectCustomerInfo" to="collectCustomerInfo" />
    </view-state>

    <view-state id="orderConfirmation" view="orderConfirmation">
        <transition on="orderConfirmed" to="processOrder" />
        <transition on="backToCollectShippingDetail" to="collectShippingDetail" />
    </view-state>

    <action-state id="processOrder" >
        <evaluate expression="orderService.saveOrder(order)" result="order.orderId"/>
        <transition to="thankCustomer" />
    </action-state>

    <view-state id="InvalidCartWarning" view="InvalidCartWarning">
        <transition to="endState"/>
    </view-state>

    <view-state id="thankCustomer" model="order" view="thankCustomer">
        <transition to="endState"/>
    </view-state>

    <end-state id="endState"/>

    <end-state id="cancelCheckout" view = "checkOutCancelled.jsp"/>

    <global-transitions>
        <transition on = "cancel" to="endState" />
    </global-transitions>

</flow>

Определения плиток для двух представлений, которые я использую в потоке:

    <definition name="collectCustomerInfo" extends="shop.base">
    <put-attribute name="title" value="Shop homepage"></put-attribute>
    <put-attribute name="body" value="/WEB-INF/flows/checkout/collectCustomerInfo.jsp"></put-attribute>
</definition>


<definition name="collectShippingDetail" extends="shop.base">
    <put-attribute name="title" value="Shop homepage"></put-attribute>
    <put-attribute name="body" value="/WEB-INF/flows/checkout/collectShippingDetail.jsp"></put-attribute>
</definition>

Вот как я вызываю переход от первого представления ко второму в jsp (из collectCustomerInfo в collectShippingDetail

                <div class="form-group">
                <div class="col-lg-offset-2 col-lg-10">
                    <input type="submit" id="btnAdd" class="btn btn-primary"
                        value="Add" name="_eventId_customerInfoCollected" />
                    <button id="btnCancel" class="btn btn-default" name="_eventId_cancel">Cancel</button>
                </div>
            </div>

2 ответа

Попробуйте использовать:

<bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.webflow.mvc.view.FlowAjaxTiles3View"/>
</bean>

и посмотреть, если вы получите другой результат

Может быть это поможет

<bean id="viewResolver"
      class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView">           
    </property>
    <property name="order" value="0" />  
</bean>

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>

<bean id="tilesConfigurer"
      class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/tiles.xml</value>
        </list>
    </property>
</bean> 
Другие вопросы по тегам