In practice, changes to a single record in a list may require many object parameters to be passed to the background server, and the Spring MVC form label <form:> provides a concise way to submit.
1 <formID= "Form1"class= "Form-horizontal chukong_form"Method= "POST"Action= "${ctx}/channel/sdkversion/postedit.do">3 <Form:hiddenPath= "Sdkversion.id" />4 <Divclass= "Form-group">5 <labelclass= "Col-sm-3 Control-label">Version number</label>6 <Divclass= "Col-sm-6">7 <Form:inputPath= "Sdkversion.sdkversion"value= "${sdkversion.sdkversion}"class= "Form-control phone1"ID= "M_version" />8 </Div>9 </Div>Ten One <Divclass= "Form-group"> A <labelclass= "Col-sm-3 Control-label">Encryption key</label> - <Divclass= "Col-sm-6"> - <Form:inputPath= "Sdkversion.itemmapperkey"value= "${sdkversion.itemmapperkey}"class= "Form-control phone1"ID= "M_itemkey" /> the </Div> - </Div> - - <Divclass= "Form-group"> + <labelclass= "Col-sm-3 Control-label">Version description</label> - <Divclass= "Col-sm-6"> + <Form:inputPath= "Sdkversion.desc"value= "${sdkversion.desc}"class= "Form-control phone1"ID= "M_desc" /> A </Div> at </Div> - - <Divclass= "Modal-footer"style= "Border:none;"> - <Divclass= "Col-sm-offset-2 col-sm-6"> - <!--<span style= "margin-right:30px;" class= ' label alert-warning ' id= ' Msgflag ' ></span> - - <Buttontype= "button"class= "Btn Searchb"ID= "Btn_submit" in Data-loading-text= "Loading ..."AutoComplete= "Off">Mention Make</Button> - <aclass= "Btn Searcha"href= "Javascript:history.go ( -1);"style= "margin:2px 1.6% 0;">Return Back</a> to </Div> + </Div> - </form>
Form Label
As with any JSP extension tag, before using the Spring form label, you must add a row to the JSP page that references the Spring form label declaration, as follows:
<%@ Page Language="Java"ContentType="text/html; Charset=utf-8"Pageencoding="UTF-8 "<%@ taglib prefix" form " Uri= "http://www.springframework.org/tags/form" %>① introduces a label declaration < Html> ... ② declaration, you can use any Spring form label on the page </html>
The resulting HTML page is:View Code
Server-side
1 @RequestMapping (value = "/sdkversion/postedit", method =Requestmethod.post)2Public String sdkversionmodify (FinalHttpServletRequest request,3Final model model,FinalSdkversion sdkversion) {4 Sdkversion.setmodifydatetime (NewDate ());5Final User CurrentUser =Sessionmanager.getcurrentuser (Request.getsession ());6 Sdkversion.setmodifyby (NewLong (Currentuser.getid ()). Intvalue ());7Try{8Sdkversionfacade.sdkversionmodify (sdkversion);9}Catch(Appexception Appex) {Ten Debug_logger.error ("Edit sdkversion fail."), Appex);11ThrowNew SystemException (Appex); 12} catch (Exception ex {13 final String error = "edit sdkversion fail." 14 Debug_logger.error (error, ex); 15 throw new16 }17 18 return "Redirect:/channel/sdkversion/query" ;< Span style= "color: #008080;" >19}
Where the value of the Sdkversion object in the form form is passed into the background as an object, without having to get the values of each property in the original form, the code is simple and easy to manipulate.
Other than that:
1. Use of check box labels
1Interest:2<Form:checkboxPath= "Favorites"Value= "1"/>Basketball3<Form:checkboxpath= "Favorites" Value= "2" /> football Span style= "color: #008080;" >4 <form:checkbox = "Favorites" value = "3" /> read 5 <form:checkbox = "Favorites" value = "4" /> tour
2. Use of the Input box label
<Path= "Sdkversion.itemmapperkey" value/>
3. Use of Radio box labels
1 Gender:<path= "Obj.sex" value= "0"/><path= "Obj.sex" value = "1"/> female
4. Use of drop-down box labels
1<Form:selectPath= "Obj.city">2<form:option Value= "" label= "--Select--"/> ① suggestive option 3 <form:options Items= "${citymap}" itemvalue= "key" itemlabel= "value"/>② true option data 4 </form:select>
Spring MVC form submission