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="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>

 

原文地址:https://www.cnblogs.com/yehuili/p/9533114.html