多条数据(子表)提交,后台处理 列子

jsp

遍历输出,以生成各个input

            <tr>
                                <td colspan="7" class="header-bgn-color">三、重要用户用电</td>
                            </tr>
                            <tr>
                                <td class="title-color">电压等级</td>
                                <td class="title-color">220kV</td>
                                <td class="title-color">110kV</td>
                                <td class="title-color">35kV</td>
                                <td class="title-color">6kV 10kV 20kV</td>
                                <td class="title-color" colspan="2">合计</td>

                            </tr>


                            <c:forEach items="${yjdlfhmajoruserloadList}" var="yjdlfhMajorUserLoad" varStatus="index">
                                <tr>
                                   <td style="display:none">  <input value="${yjdlfhMajorUserLoad.id}"  name="yjdlfhmajoruserload.id"  ></td>
                                   <td style="display:none">  <input value="${yjdlfhzb.id}"  name="yjdlfhmajoruserload.refid"  ></td>
                                   <td style="display:none">  <input value="${yjdlfhMajorUserLoad.xh}"  name="yjdlfhmajoruserload.xh"  ></td>
                                    <td><input value="${yjdlfhMajorUserLoad.dydj}"  name="yjdlfhmajoruserload.dydj"  class="  readonly myInputSubText"></td>
                                    <td><input value="${yjdlfhMajorUserLoad.kV220}"  name="yjdlfhmajoruserload.kV220" class=" myInputSubText"></td>
                                    <td><input value="${yjdlfhMajorUserLoad.kV110}"  name="yjdlfhmajoruserload.kV110"class=" myInputSubText"></td>
                                    <td><input value="${yjdlfhMajorUserLoad.kV35}"  name="yjdlfhmajoruserload.kV35" class=" myInputSubText"></td>
                                    <td><input value="${yjdlfhMajorUserLoad.kV61020}"  name="yjdlfhmajoruserload.kV61020" class=" myInputSubText"></td>
                                    <td colspan="2"><input value="${yjdlfhMajorUserLoad.hj}"  name="yjdlfhmajoruserload.hj" class=" myInputSubText"></td>
                                </tr>

                            </c:forEach>
View Code

 

java

获取以及封装到实体类

    private void addUserload(HttpServletRequest request, Yjdlfhzb yjdlfhzb) {
        List<Yjdlfhmajoruserload> yjdlfhmajoruserloadList  = new ArrayList<Yjdlfhmajoruserload>();
        String[] dydj = request.getParameterValues("yjdlfhmajoruserload.dydj");
        String[] kV220 = request.getParameterValues("yjdlfhmajoruserload.kV220");
        String[] kV110 = request.getParameterValues("yjdlfhmajoruserload.kV110");
        String[] kV35 = request.getParameterValues("yjdlfhmajoruserload.kV35");
        String[] kV61020 = request.getParameterValues("yjdlfhmajoruserload.kV61020");
        String[] hj = request.getParameterValues("yjdlfhmajoruserload.hj");
        String[] xh = request.getParameterValues("yjdlfhmajoruserload.xh");
        
        for(int i=0;i<dydj.length;i++){
            Yjdlfhmajoruserload e = new Yjdlfhmajoruserload();
            e.setDydj(dydj[i]);
            e.setkV220(kV220[i]);
            e.setkV110(kV110[i]);
            e.setkV35(kV35[i]);
            e.setkV61020(kV61020[i]);
            e.setHj(hj[i]);
            if(xh[i].length()>0){
                e.setXh(Long.parseLong(xh[i]));
            }
            e.setByzddate(yjdlfhzb.getRq());
            yjdlfhmajoruserloadList.add(e);
        }
        yjdlfhzb.setYjdlfhmajoruserloadList(yjdlfhmajoruserloadList);
    }
View Code

 

posted @ 2021-03-15 10:28  爱跳舞的程序员  阅读(75)  评论(0编辑  收藏  举报