Wie werde ich geben Sie in web-flow aus jedem beliebigen Punkt in der Spring-MVC-web-app? Spring Web Flow webapp funktioniert nicht
Habe ich versucht, die Entwicklung einer multi-page-Benutzer-Registrierung-form mit Spring Web Flow, konnte aber nicht abgeschlossen. Später werde ich einfügen mein code der Anwendung in diesem post.
Ich wäre dankbar für jemanden zu identifizieren, den fehlenden Teil oder Fehler und führen mich zu lösen das gleiche.
Meine webapp name 'UserRegistrationSWF'. Hier ist die Verzeichnis-Struktur:
UserRegistrationSWF
-Java Resources
-src
-org.nitest.controller
-UserRegistrationController.java
-org.nitesh.model
-User.java
-WebContent
-WEB-INF
-config
-swf-config.xml
-web-application-config.xml
-swf
-swf-flow.xml
-userRegistrationPage2.jsp
-userRegistrationLastPage.jsp
-view
-cancel.jsp
-success.jsp
-userRegistrationStartPage.jsp
-web.xml
-index.jsp
Bin ich mit Spring MVC und meine willkommen-Seite 'index.jsp'. Hier ist der code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome Page</title>
</head>
<body>
<a href="userRegistrationStartPage.htm">User Registration</a>
</body>
</html>
Ist hier 'web.xml' code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web- app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>UserRegistrationSWF</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/web-application-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>User Registration</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>User Registration</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
</web-app>
Hier ist 'web-application-config.xml' code:
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">
<mvc:annotation-driven/>
<context:component-scan base-package="org.nitesh" />
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
<import resource="swf-config.xml"/>
</beans>
Hier ist 'swf-config.xml' code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans">
<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF">
<webflow:flow-location path="/swf/swf-flow.xml" />
</webflow:flow-registry>
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
</webflow:flow-executor>
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry"/>
</bean>
</beans>
Hier ist 'swf-flow.xml' code:
<?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-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">
<view-state id="userRegistrationStartPage" view="userRegistrationStartPage.htm" model="user">
<transition on="cancel" to="cancel"></transition>
<transition on="proceed" to="userRegistrationPage2"></transition>
</view-state>
<view-state id="userRegistrationPage2" view="userRegistrationPage2.htm">
<transition on="revise" to="userRegistrationStartPage"></transition>
<transition on="proceed" to="userRegistrationLastPage"></transition>
<transition on="cancel" to="cancel"></transition>
</view-state>
<view-state id="userRegistrationLastPage" view="userRegistrationLastPage.htm">
<transition on="revise" to="userRegistrationPage2"></transition>
<transition on="confirm" to="success"></transition>
<transition on="cancel" to="cancel"></transition>
</view-state>
<end-state id="success" view="swf/success.jsp"></end-state>
<end-state id="cancel" view="swf/cancel.jsp"></end-state>
</flow>
Hier ist 'userRegistrationStartPage.jsp' code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>User Registration Start Page</title>
</head>
<body>
<form:form commandName="user" method="POST">
<table>
<tr>
<td>Name:</td>
<td><form:input path="name"/></td>
</tr>
<tr>
<td>Email:</td>
<td><form:input path="email"/></td>
</tr>
<tr>
<td>Password:</td>
<td><form:password path="password"/></td>
</tr>
<tr>
<td><input type="submit" name="_eventId_cancel" value="Cancel"></td>
<td><input type="submit" name="_eventId_proceed" value="Next"></td>
</tr>
</table>
</form:form>
</body>
</html>
'Abbruch.jsp' und 'Erfolg.jsp' druckt einfach Abbrechen und Erfolg-Nachricht bzw.
Der 'User' - Klasse ist eine userRegistrationStartPage form bean-Klasse.
Die 'userRegistrationPage2.jsp' und 'userRegistrationLastPage.jsp' Einfach druckt messgage für jetzt.
Hier ist die web-app-controller 'UserRegistrationController.java' code:
package org.nitesh.controller;
import org.nitesh.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class UserRegistrationController {
@RequestMapping(value = "userRegistrationStartPage.htm")
public ModelAndView showUserRegistrationFormStartPage(@ModelAttribute("user") User user)
{
return new ModelAndView("userRegistrationStartPage");
}
}
Vorstehenden ist die web-app codes.
Nun würde ich gerne kommen meine Fragen:
1. Wie werde ich geben Sie in web-flow aus jedem beliebigen Punkt in der Spring-MVC-web-app? Ich meine, wie werde ich den Eintrag in web-flow, indem Sie auf folgenden link " - index.jsp':
<a href="userRegistrationStartPage.htm">User Registration</a>
- Oben genannten webapp funktioniert nicht, was fehlt, die ich hinzufügen oder ändern müssen, damit es funktioniert?
Ich bin wirklich gespannt auf die Antwort zu hören von einem.
Dank.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Du bist fast da:
Es ist eine bewährte Methode, um alle Elemente Ihrer Strömung in einem Ordner. So bewegen sich die erste Seite der Fluss mit dem Namen 'userRegistrationStartPage.jsp' aus /Ansicht/zu /swf/
Weil Sie definiert, die eine Strömung in Ihrem swf-config.xml
Die Zuordnung zu beginnen, die Strömung wird swf (der erste Teil des Pfades)
Ändern Sie Ihren index.jsp auf den folgenden
Auch, weil Sie mit einem User-Objekt zum speichern der Registrierungsdaten, die Sie brauchen, um eine zu erstellen am Anfang der Strömung. Siehe die Buchung-mvc Beispiel von spring webflow, wo ein Hotel-Objekt benötigt wird, bei Beginn der Strömung:
Hier Sie einen Dienst nutzen, um ein hotel aus der Datenbank, YMMV.
Schließlich die UserRegistrationController nicht erforderlich ist, so können Sie es entfernen.
Update
Den schnellsten Weg zu erstellen Sie ein neues Benutzer-Objekt am Anfang der Blutung würde es sein, fügen Sie die folgende Zeile am Anfang swf-flow.xml: