Last time I said that the current page needs to load more than one data class, and the foreground page only has a form form, how do we do the data echo.
To solve this problem, the team members discussed the ability to return data to the page instead of returning it to the form, so there was a development pattern of multiple form submissions with Layer (Web shell component) and multiple form data echoes.
Take a look at the original front page
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%><% String Path = Request.getcontextpath () ; String basepath = request.getscheme () + "://" + request.getservername () + ":" + request.getserverport () + path + "/";%> <! DOCTYPE html>In this JSP
We can see that this page contains the model as well as the form, and if you want to replace the layer popup, then we need to choose the model separately from the form.
Here, I'll take housebase for example.
Add a layer of JS
Click Add
Showmodel () the corresponding JS
function Showmodel () {$.post (' housebase/addoreditpage.do ', {dtypecode: "19,26,32,33,30,9"}, function (str) { Layer.open ({ title: ' House data added ', type:1, maxmin:true, shade:0, area : ' 1100px ', content:str/ /Note that if STR is an object, then the character stitching is required. });});}
Then take a look at housebase/addoreditpage.do corresponding controller, this is the key to solve the return value, get different entity classes, through Model.addattribute to Housebase_model page, Then use the dollar sign at the front desk to value
@RequestMapping (value= "addoreditpage") public String toadd (httpservletrequest req,model model,long UpdateID) {/* Determines whether the update is empty, if not NULL, data echo */if (updateid!=null) {/* Gets the home location information entity class object */houseposition by the primary key ID hp= Houseposservice.selectbyprimarykey (UpdateID);/* Transfer the object back to Model*/model.addattribute ("Hpos", HP);/* Get Housing Information entity class object by primary Key ID */ Houseinfo hi = Houseinfo.selectbyforeignkey (UpdateID);/* Transfer the object back to Model*/model.addattribute ("HInfo", hi);/* Obtain the Householder basic information entity class object through the primary key ID */houseowner ho = houseowner.selectbyforeignkey (UpdateID);/* Returns the object to Model*/model.addattribute (" Hown ", ho);} return "House/model/housebase_model";}
The hInfo of this is Model.addattribute ("HInfo", HI); hInfo
The controller returns the corresponding model page,
Using <% @include file= ""%> contains three different form elements in the model
This is one of the forms.
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%><div id= "HouseOwner" class= " Form-horizontal "><input type=" hidden "name=" hown.id "value=" ${hown.id} "/><div class=" Form-group "> <label class= "col-sm-2 control-label" for= "name" > Householder name </label><div class= "col-sm-4" ><input type = "text" class= "Form-control" name= "Hown.oname" value= "${hown.oname}" placeholder= "></div><label class= "Col-sm-2 Control-label" for= "Cardtype" > Credential type </label><div class= "col-sm-4" ><select id= "OCardtype" Name= "Hown.ocardtype" class= "Form-control" ><c:foreach var= "value" items= "${combox9}" > <option Value= "${value.dcode}" <c:if test= "${value.dcode==hown.ocardtype}" >selected</c:if>>${value.dname} </option> </c:foreach></select></div></div><div class= "Form-group" ><la Bel class= "Col-sm-2 Control-label" for= "cardnum" > ID number </label><div Class= "col-sm-4" ><input type= "text" class= "Form-control" name= "Hown.ocardnum" value= "${hown.ocardnum}" Placeholder= "" ></div><label class= "col-sm-2 control-label" for= "Contact" > Contacts </label><div class= "col-sm-4" ><input type= "text" class= "Form-control" name= "Hown.ocontact" value= "${hown.ocontact}" Placeholder= "" ></div></div></div>
The first project of a freshman (III.)