0
情況:我正在開發一個spring MVC webapp並使用spring web flow和tiles框架。我在DB customer
和customerAdress
中有兩個表格,我有兩個表格,分別命名爲customerModel
和customerAdressModel
。如何將多個模型綁定到Spring Web Flow中的單個視圖?
我現在有以下view-state
:
<var name = "cust" class = "com.model.CustomerModel"/>
<view-state id = "customerViewState" view = "customer" model = "cust">
<transition on="next" to="customerData"/>
</view-state>
磁磚框架可解決其在下面示出的視圖customer
撥出customer.jsp
:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!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">
</head>
<body>
<div>
<form id="Form" method="post" enctype="multipart/form-data" class="form-
inline">
<div class="inputDiv">
<label class="inputLabel"> Name :</label>
<input type="text" name="name" id="name">
<label class="inputLabel">Email :</label>
<input type="email" name="email" id="email">
</div>
<input type="button" id="forwardButton" value="Next"/>
</form>
</div>
</body>
<script>
$("#forwardButton").click(function(){
$("#WlDetailsForm").attr('action','${flowExecutionUrl}&_eventId=next');
$("#WlDetailsForm").submit();
});
</script>
</html>
問題:現在customer.jsp
中指定的格式具有一些輸入字段,其中包含customerAdressModel
的屬性值。因此,我想綁定customerModel
以及customerAdressModel
到相同的視圖狀態customerViewState
。我怎麼做,我經歷了春季DOC,但沒有找到任何東西,請幫助!
注:我不能改變我的SQL表
替換形式,在你的JSP什麼的一組語句做,他們爲什麼需要? –
@varunsinghal'set'語句將'value'表達式結果設置爲'name'中定義的屬性。 ' '表示'customerDto.setCustomer(cust)'。這兩套都需要將客戶和地址設置到DTO中,以便在jsp中引用它們。 –
Evgeny
有一個疑問,我有一個buisness服務,它將customerModel作爲輸入參數,然後將該輸入參數插入到customer表中。我將如何實現這一目標?我可以這樣做:cusomerBuisness.createCustomer(customerDto.cust)?請幫忙 ! –