状況:私は春のMVC Webアプリケーションを開発しており、春のWebフローとタイルフレームワークを使用しています。私はDB customer
とcustomerAdress
の2つのテーブルを持っており、私はcustomerModel
とcustomerAdressModel
という2つのモデルクラスを持っています。春のWebフローで複数のモデルを単一のビューにバインドする方法はありますか?
は今私のflow.xmlに私は次のよう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.jsp
を充当するビューcustomer
を解決します
<%@ 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
のプロパティの値を含む入力フィールドをいくつか持っています。バインドしたいですか同じビュー状態customerViewState
にはとcustomerAdressModel
が含まれています。どのように私はそれを行う、私は春のDOCを通過したが、何かを見つけるcouldnt、助けてください!
注:私は私のSQLテーブル変更カント
であなたのJSPにフォームを置き換え、なぜ彼らが必要としていますか? –
@varunsinghal 'set'文は、' value'式の結果を 'name'で定義された属性に設定します。 ' は' customerDto.setCustomer(cust) 'を意味します。どちらのセットも、顧客と住所をjspで参照するためにDTOに設定する必要があります。 –
Evgeny
1つの疑問は、私は入力パラメータとしてcustomerModelを受け取り、その入力パラメータをcustomerテーブルに挿入するビジネスサービスを持っています。どうすればここでそれを達成できますか?私はこのようにすることができます:cusomerBuisness.createCustomer(customerDto.cust)?助けてください ! –