SpringMVC from 表單標簽和 input 表單標簽
阿新 • • 發佈:2018-06-08
cape rep mission photo div eml wid arch ext
我們先來看如下使用form標簽的一個示例:
input :一般的表單
剛學習很懵 不知道還有springmvc 自己的表單 於是乎就上網查了一下 這個真的好用多啦
剛學習很懵 不知道還有springmvc 自己的表單 於是乎就上網查了一下 這個真的好用多啦
剛學習很懵 不知道還有springmvc 自己的表單 於是乎就上網查了一下 這個真的好用多啦
詳細信息 springmvc 表單大全喲@
https://www.yiibai.com/spring_mvc/
1. form標簽 使用Spring的form標簽主要有兩個作用,第一是它會自動的綁定來自Model中的一個屬性值到當前form對應的實體對象,默認是command屬性,這樣我們就可以在form表單體裏面方便的使用該對象的屬性了;第二是它支持我們在提交表單的時候使用除GET和POST之外的其他方法進行提交,包括DELETE和PUT等。 1.1 支持綁定表單對象- <form:form action="formTag/form.do" method="post">
- <table>
- <tr>
- <td>Name:</td><td><form:input path="name"/></td>
- </tr>
- <tr>
- <td>Age:</td><td><form:input path="age"/></td>
- </tr>
- <tr>
- <td colspan="2"><input type="submit" value="提交"/></td>
- </tr>
- </table>
- </form:form>
- <form id="command" action="formTag/form.do" method="post">
- <table>
- <tr>
- <td>Name:</td><td><input id="name" name="name" type="text" value="ZhangSan"/></td>
- </tr>
- <tr>
- <td>Age:</td><td><input id="age" name="age" type="text" value="36"/></td>
- </tr>
- <tr>
- <td colspan="2"><input type="submit" value="提交"/></td>
- </tr>
- </table>
- </form>
1 <body> 2 <ul class="nav nav-tabs"> 3 <li><a href="${ctx}/academic/expert/">專家學者列表</a></li> 4 <li class="active"><a href="${ctx}/academic/expert/form?id=${expert.id}">專家學者<shiro:hasPermission name="academic:expert:edit">${not empty expert.id?‘修改‘:‘添加‘}</shiro:hasPermission><shiro:lacksPermission name="academic:expert:edit">查看</shiro:lacksPermission></a></li> 5 </ul><br/> 6 <form:form id="inputForm" modelAttribute="expert" action="${ctx}/academic/expert/save" method="post" class="form-horizontal"> 7 <form:hidden path="id"/> 8 <sys:message content="${message}"/> 9 <div class="control-group"> 10 <label class="control-label">姓名:</label> 11 <div class="controls"> 12 <form:input path="fullName" htmlEscape="false" maxlength="255" class="input-xlarge required"/> 13 <span class="help-inline"><font color="red">*</font> </span> 14 </div> 15 </div> 16 <div class="control-group"> 17 <label class="control-label">姓名首字母:</label> 18 <div class="controls"> 19 <form:select path="initialName" class="input-small "> 20 <form:option value="" label=""/> 21 <form:option value="A" label="A" /> 22 <form:option value="B" label="B" /> 23 <form:option value="C" label="C" /> 24 <form:option value="D" label="D" /> 25 <form:option value="E" label="E" /> 26 <form:option value="F" label="F" /> 27 <form:option value="G" label="G" /> 28 <form:option value="H" label="H" /> 29 <form:option value="I" label="I" /> 30 <form:option value="J" label="J" /> 31 <form:option value="K" label="K" /> 32 <form:option value="L" label="L" /> 33 <form:option value="M" label="M" /> 34 <form:option value="N" label="N" /> 35 <form:option value="O" label="O" /> 36 <form:option value="P" label="P" /> 37 <form:option value="Q" label="Q" /> 38 <form:option value="R" label="R" /> 39 <form:option value="S" label="S" /> 40 <form:option value="T" label="T" /> 41 <form:option value="U" label="U" /> 42 <form:option value="V" label="V" /> 43 <form:option value="W" label="W" /> 44 <form:option value="X" label="X" /> 45 <form:option value="Y" label="Y" /> 46 <form:option value="Z" label="Z" /> 47 </form:select> 48 49 <span class="help-inline"><font color="red">*</font> </span> 50 </div> 51 </div> 52 <div class="control-group"> 53 <label class="control-label">頭像:</label> 54 <div class="controls"> 55 <form:hidden id="nameImage" path="photo" htmlEscape="false" maxlength="255" class="input-xlarge"/> 56 <sys:ckfinder input="nameImage" type="images" uploadPath="/academic/expert" selectMultiple="false" maxWidth="100" maxHeight="100"/> 57 </div> 58 </div> 59 <div class="control-group"> 60 <label class="control-label">國家:</label> 61 <div class="controls"> 62 <form:select path="country" class="input-xlarge required"> 63 <form:option value="" label=""/> 64 <form:options items="${fns:getDictList(‘country‘)}" itemLabel="label" itemValue="value" htmlEscape="false"/> 65 </form:select> 66 <span class="help-inline"><font color="red">*</font> </span> 67 </div> 68 </div> 69 <div class="control-group"> 70 <label class="control-label">是否在首頁顯示:</label> 71 <div class="controls"> 72 <form:radiobuttons path="isShowHomepage" items="${fns:getDictList(‘yes_no‘)}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/> 73 <span class="help-inline"><font color="red">*</font> </span> 74 </div> 75 </div> 76 <div class="control-group"> 77 <label class="control-label">工作單位:</label> 78 <div class="controls"> 79 <form:input path="orgName" htmlEscape="false" maxlength="255" class="input-xlarge "/> 80 </div> 81 </div> 82 <%--<div class="control-group"> 83 <label class="control-label">所屬研究機構:</label> 84 <div class="controls"> 85 <c:if test="${not empty expert.id }"> 86 ${expert.studyBranch} 87 </c:if> 88 </div> 89 </div>--%> 90 <div class="control-group"> 91 <label class="control-label">職稱職務:</label> 92 <div class="controls"> 93 <form:input path="position" htmlEscape="false" maxlength="255" class="input-xlarge "/> 94 </div> 95 </div> 96 <div class="control-group"> 97 <label class="control-label">個人簡介:</label> 98 <div class="controls"> 99 <form:textarea path="info" htmlEscape="false" rows="4" maxlength="5000" class="input-xxlarge "/> 100 </div> 101 </div> 102 <div class="control-group"> 103 <label class="control-label">研究領域:</label> 104 <div class="controls"> 105 <form:textarea path="research" htmlEscape="false" rows="4" maxlength="500" class="input-xxlarge "/> 106 </div> 107 </div> 108 <div class="control-group"> 109 <label class="control-label">研究成果:</label> 110 <div class="controls"> 111 <form:textarea id="majorWorks" htmlEscape="false" path="majorWorks" rows="4" class="input-xxlarge"/> 112 <sys:ckeditor replace="majorWorks" uploadPath="/academic/expert" /> 113 </div> 114 </div> 115 <%--<div class="control-group">--%> 116 <%--<label class="control-label">論文:</label>--%> 117 <%--<div class="controls">--%> 118 <%--<form:textarea id="paper" htmlEscape="false" path="paper" rows="4" class="input-xxlarge"/>--%> 119 <%--<sys:ckeditor replace="paper" uploadPath="/academic/expert" />--%> 120 <%--</div>--%> 121 <%--</div>--%> 122 123 <div class="control-group"> 124 <label class="control-label">備註信息:</label> 125 <div class="controls"> 126 <form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/> 127 </div> 128 </div> 129 <div class="form-actions"> 130 <shiro:hasPermission name="academic:expert:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/> </shiro:hasPermission> 131 <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/> 132 </div> 133 </form:form> 134 </body>
哈哈哈哈 好喜歡 喲 歡迎吐槽
SpringMVC from 表單標簽和 input 表單標簽