Freigeben von Objekten über Bildschirme mithilfe von Spring Webflow

Ich versuche, etwas einzurichten, das zum Beispiel wie ein Vorgang zum Einrichten einer Buchung auf mehreren Bildschirmen aussieht.

Bildschirm 1 Persönliche Informationen hinzufügenBildschirm 2 KontaktinformationenBildschirm 3 Zusammenfassung und bestätigen

Ich habe meinen .jsp- und xml-Webflow sowie alle Klassen eingerichtet, habe jedoch Probleme, sie zu verknüpfen. Ich möchte zu Beginn des Ablaufs eine Konto-Klasse erstellen. Wenn der erste Bildschirm ausgefüllt ist, werden die Informationen in dieser Klasse gespeichert. Wenn der Benutzer am letzten Bildschirm die Zusammenfassung auf der Grundlage der von ihm angegebenen Informationen anzeigen und gegebenenfalls überarbeiten kann, werden die Informationen beim Zurückkehren zum ersten Bildschirm bereits für ihn ausgefüllt, sodass er sie nicht erneut eingeben muss.

Es tut mir leid für die Code-Wand. Ich habe versucht, es auf die möglichen Stellen für einen Fehler zu beschränken, der mir einfällt.

Meine flow-config.xml

<?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-2.0.xsd">

    <on-start>
        <evaluate expression="BookingManagementService.createBooking()" result="flowScope.booking" />
    </on-start>

    <view-state id="flow-config"  view="booking/BookingIdentificationScreen" model="booking">
    <binder>
        <binding property="username" />
    </binder>
    <transition on="next" to="enterContactDetails"/>
    <transition on="cancel" to="cancel"/>
</view-state>
    ... 
</flow>

Meine allgemeine servlet-context.xml

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

    <annotation-driven />

    <resources mapping="/resources/**" location="/resources/" />

    <beans:bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

    <context:component-scan base-package="com.mycompany.myapp" />

    <beans:bean id="handlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
    <beans:bean name="/index.do" class="com.mycompany.myapp.IndexController" />
    <beans:bean name="/home.do" class="com.mycompany.myapp.HomeController" />

    <beans:bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <beans:property name="mappings" value="/account/flow-config.do=flowController" />
        <beans:property name="alwaysUseFullPath" value="true"/>
    </beans:bean>

    <!-- SPRING WEB FLOW STUFF -->
    <beans:bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
        <beans:property name="flowExecutor" ref="flowExecutor"/>
    </beans:bean>

    <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry"/>

    <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
        <webflow:flow-location path="/WEB-INF/config/flow-config.xml"/>
    </webflow:flow-registry>

    <webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="viewFactoryCreator"/>

    <beans:bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
        <beans:property name="viewResolvers">
            <beans:list>
                <beans:ref bean="viewResolver"/>
            </beans:list>
        </beans:property>
    </beans:bean>

</beans:beans>

BookingManagementService.java

@Service("bookingService")
public class BookingManagementService{
    @Transactional(readOnly = true)
    public BookingIpl createBooking(Long hotelId, String username) {
        BookingIpl booking= new BookingIpl();
        return booking;
    }
}

BookingIpl.java

@Entity
public class BookingIpl implements Serializable {
    public String username;
    ...
}

IndexController

   @Controller
   public class IndexController extends AbstractController {
    private BookingManagementService bookingService;

    @Autowired
    public IndexController(BookingManagementService bookingService) {
        this.bookingService = bookingService;
    }
    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest arg0,
            HttpServletResponse arg1) throws Exception {
        return new ModelAndView("index");
    }
}

Also hätte ich in meinen Java-Skripten für den ersten Bildschirm etwas wie:

<form:form modelAttribute="booking" action="${flowExecutionUrl}" method="post">
     <form:input type="text" path="username"/>
</form:form>

und nach der Aufforderung zum nächsten Bildschirm möchte ich den Wert beispielsweise in einer Zusammenfassung zurückgeben

 <form:form modelAttribute="booking" action="${flowExecutionUrl}" method="post">
         <spring:bind path="username">${status.value}</spring:bind>
    </form:form>

Der Fehler, den ich erhalte, ist in etwa so:

SEVERE: Servlet.service() for servlet [appServlet] in context with path [/myapp] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@778e65f2 targetAction = [EvaluateAction@25c73030 expression = bookingService.createBooking(), resultExpression = flowScope.booking], attributes = map[[empty]]] in state 'null' of flow 'flow-config' -- action execution attributes were 'map[[empty]]'] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'bookingService' cannot be found on object of type 'org.springframework.webflow.engine.impl.RequestControlContextImpl'

Ich habe eine andere Methode ausprobiert, um all das zu tun, die eine Bean in meinem Servlet wie folgt definiert:

<beans:bean id="bookingBean" class="com.mycompany.myapp.BookingIpl" scope="prototype" />

aber das hat auch nicht geholfen, gab den gleichen fehler.

Ich bin sehr neu in Web-Flow und Spring, bitte verzeihen Sie mir, wenn der Fehler, den ich gemacht habe, etwas Offensichtliches war.

Vielen Dank

Antworten auf die Frage(2)

Ihre Antwort auf die Frage