springMVC中的form:標簽使用
(1)modelAttribute的值是用於提交到後臺的實體類對象名稱
(2)form:select path的值要對應實體類的屬性值
<form:form id="searchForm" modelAttribute="reportTask" action="${ctx}/reporttask/reportTask/reviewList" method="post" class="breadcrumb form-search">
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<ul class="ul-form">
<li><label>文件名稱:</label>
<form:select path="transferFileName" class="input-medium ">
<form:option value="" label="---請選擇---"/>
<form:options items="${fns:getTableName()}" itemLabel="tableName" itemValue="transferFileName" htmlEscape="false"/>
</form:select>
</li>
<li><label>版本:</label>
<form:select path="version" class="input-medium ">
<form:option value="V3.0" label="V3.0"/>
<form:option value="V2.0" label="V2.0"/>
<form:option value="V1.0" label="V1.0"/>
</form:select>
</li>
<li><label>所屬機構:</label>
<sys:mytreeselect id="company" name="reportJG" checked="true" cssStyle="width:125px;" value="${reportJG}" labelName="company.name" labelValue="${reportJGname }"
title="機構" url="/sys/office/treeData?" cssClass=" required span4Tree" dataMsgRequired="必填信息" allowClear="true"/>
</li>
<li><label>數據日期:</label>
<input name="subTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
value="2017-06-28"
onclick="WdatePicker({dateFmt:‘yyyy-MM-dd‘});"/>
</li>
<li>
<a href="javascript:;" id="btnSubmit" style="margin-left: 10px;" class="search-btn" onclick="findTask()" title="查詢">查詢</a>
<a href="javascript:;" id="btnSubmit" class="search-btn" onclick="findTask()" title="復核通過">復核通過</a>
<a href="javascript:;" id="btnSubmit" class="search-btn" onclick="findTask()" title="復核打回">復核打回</a>
</li>
</ul>
</form:form>
(3)全選全不選和獲取全選的值
//全選/反選
function selectAll(){
var checkboxs = document.getElementsByName("checkbox");
var checkall = document.getElementById("checkAll");
if(checkall.checked){
for(var i =0;i<checkboxs.length;i++){
checkboxs[i].checked = true;
}
}else{
for(var j =0;j<checkboxs.length;j++){
checkboxs[j].checked = false;
}
}
}
//獲取選中的checkbox的值
function getCheckedValue(checkName) {
var str = "";
if (checkName) {
$("input:checkbox[name=‘" + checkName +"‘]:checked").each(function() {
if ($(this).attr("checked")) {
if (str == "") {
str += $(this).val();
} else {
str += "," + $(this).val();
}
}
});
} else {
$("input[name=type]:checkbox").each(function() {
if ($(this).attr("checked")) {
if (str == "") {
str += $(this).val();
} else {
str += "," + $(this).val();
}
}
});
}
return str;
}
<table id="contentTable" > <thead> <tr> <th><input type="checkbox" id="checkAll"onclick="selectAll()"></th> <th>計劃名稱</th> <th>模板名稱</th> <th>版本</th> <th>執行類型</th> <th>頻度</th>
</tr> </thead> <tbody>
<c:forEach items="${page.list}" var="reportplan"> <tr class="even"> <td><input type="checkbox" name="checkbox"value="${reportplan.planId}"></td> <td>${reportplan.planName}</td> <td>${reportplan.templateName}</td> <td>${reportplan.templateVersion}</td>
<td> <c:if test="${reportplan.isAuto eq ‘0‘}">手動</c:if> <c:if test="${reportplan.isAuto eq ‘1‘}">自動</c:if> </td> <td> <c:if test="${reportplan.frequentness eq ‘D‘}">日</c:if> <c:if test="${reportplan.frequentness eq ‘W‘}">周</c:if> <c:if test="${reportplan.frequentness eq ‘M‘}">月</c:if> <c:if test="${reportplan.frequentness eq ‘J‘}">季</c:if> <c:if test="${reportplan.frequentness eq ‘HY‘}">半年</c:if> <c:if test="${reportplan.frequentness eq ‘Y‘}">年</c:if> </td>
<td width="0" class="last_td" style="position:relative;"> <div class="tr_pop_box"> <ul>
<li> <ahref=‘${ctx}/reportplan/reportplan/form?planId=${reportplan.planId}‘title="修改"><img src="${ctxStatic}/images/tr_icon_02.png" alt=""/></a> </li>
<li> <a href="javascript:;" onclick="deletePlan(‘${reportplan.planId}‘)" title="刪除"><imgsrc="${ctxStatic}/images/tr_icon_04.png" alt=""/></a>
</li> </ul> </div> </td> </tr> </c:forEach> </tbody> </table> |
springMVC中的form:標簽使用