之前做过打印,需要循环遍历多个div,同时需要给id加编号,经过百度搜索,终于让我找到,在此记录一下如何实现:
<c:forEach items="${list}" var="m" varStatus="status">
<div style="width: 210mm; height: 76.2mm;" id="page${status.index + 1}" class="only_for_print jp-page">
<div class="jp-text jp-comp-1 my-f1" id='f1' draggable='true'>
${m.empname }
</div>
<div class="jp-text jp-comp-2 my-f2" id='f2' draggable='true'>
${m.evename}
</div>
<div class="jp-text jp-comp-3 my-f3" id='f3' draggable='true'>
${m.optb}
</div>
<div class="jp-text jp-comp-4 my-f4" id='f4' draggable='true'>
${m.operperson }
</div>
<div class="jp-text jp-comp-5 my-f5" id='f5' draggable='true'>
${m.checkperson }
</div>
<div class="jp-text jp-comp-6 my-f6" id='f6' draggable='true'>
${m.getYear}
</div>
<div class="jp-text jp-comp-7 my-f7" id='f7' draggable='true'>
${m.getMonth}
</div>
<div class="jp-text jp-comp-8 my-f8" id='f8' draggable='true'>
${m.getDate}
</div>
<div class="jp-text jp-comp-9 my-f9" id='f9' draggable='true'>
${m.datecode}
</div>
</div>
<form class="jl-form" >
<input type="text" class="b-0 input-9" name="empname" value="${m.empname }">
<input type="text" class="b-0 input-10" style="text-align: left;" name="evename" value="${m.evename}">
<input type="text" class="b-0 input-11" id="optb" name="optb" value="${m.optb}">
<input type="text" class="b-0 input-12" id="operperson" name="operperson" value="${m.operperson }">
<input type="text" class="b-0 input-13" value="${m.checkperson }">
<input type="text" class="b-0 input-14" value="${m.getYear}">
<input type="text" class="b-0 input-15" value="${m.getMonth}">
<input type="text" class="b-0 input-16" value="${m.getDate}">
<input type="text" class="b-0 input-17" value="${m.datecode}">
</form>
</c:forEach>