jsp中常用的<c:if>判断非空的方法:
<c:if test="${empty obj.glyhf}">为空</c:if> //为空显示
<c:if test="${not empty obj.glyhf}">不为空</c:if> //不为空显示
<c:if>判断表单字段,重复${${}}时:这时候直接把里层的${}去掉就可以了。
<c:if test="${prostate=='WC'&& yhpjlist.items[0].pjnr==null }">
<tr>
<td style="width: 50%;" colspan="2">
<em class="gw_h2">评价内容:</em> <em> <f:field column="SBBX_YHPJ.pjnr" value="${yhpjlist.items[0].pjnr}"> </f:field></em>
</td>
</tr>
<tr>
<td style="width: 50%;" colspan="2">
<em class="gw_h2">满意度:</em> <em> <f:field column="SBBX_YHPJ.myd" value="${yhpjlist.items[0].myd}"> </f:field></em>
</td>
</tr>
</c:if>
js动态添加表格,将数据存入子表中,然后用<c:forEach>取出时:
function addsyhc(){
var unid=Math.uuid();
var tr='<tr id="'+unid+'" class="mytr" valign="middle">';
tr+='<td width="25%" align="center">';
tr+='<input comments="耗材分类" style="width:130px" id="hcfl'+unid+'" name="SBBX_SYHC'+unid+'.hcfl" notnull="false" nullalert="" type="text" value="">';
tr+='<input type="hidden" name="SBBX_SYHC.unid" value="'+unid+'" /> ';
tr+='<input type="hidden" name="SBBX_SYHC'+unid+'.parentid" value="${formlist.items[0].unid}" /> ';
tr+='</td>';
tr+='<td width="25%" align="center">';
tr+='<input comments="耗材名称" style="width:130px" id="SBBX_SYHC'+unid+'.hcmc" name="SBBX_SYHC'+unid+'.hcmc" notnull="false" nullalert="" type="text" value="">';
tr+='</td>';
tr+='<td width="25%" align="center">';
tr+='<input comments="耗材数量" style="width:120px" id="SBBX_SYHC'+unid+'.hcsl" name="SBBX_SYHC'+unid+'.hcsl" notnull="false" nullalert="" type="text" value="" />';
tr+='</td>';
tr+='<td align="center" width="10%">';
tr+=' <a href="javascript:void(0);" style="color:red" οnclick="deletegzlb(\''+unid+'\');">删除</a>';
tr+='</td>';
$("#syhctable").append(tr);
}
function deletegzlb(unid){
$("#"+unid).remove();
var value="SBBX_SYHC,"+unid;
var delteInput='<input type="hidden" name="delete.unid" value="'+value+'"/>';
$("#deleteem").append(delteInput);
}
在jsp中用<for:each>取出来:
<table id="syhctable" border="0" cellpadding="0" cellspacing="0" width="500px">
<tr>
<td height="25" align="center" >耗材分类</td>
<td height="25" align="center">耗材名称</td>
<td height="25" align="center">数量</td>
<td height="25" align="center"><a style="color:green;font-weight:bold;" href="javascript:void(0);" οnclick="addsyhc();" >添加</a></td>
</tr>
<c:forEach var="syhc" items="${syhclist.items}" varStatus="status">
<tr id="${syhc.unid}" class="mytr" valign="middle">
<td width="150px" height="25" align="center">
<input comments="耗材分类" id="hcfl${syhc.unid}" name="SBBX_SYHC${syhc.unid}.hcfl" notnull="false" nullalert="" type="text" value="${syhc.hcfl}" />
<input type="hidden" name="SBBX_SYHC.unid" value="${syhc.unid}" />
</td>
<td width="150px" height="25" align="center">
<input comments="耗材名称" id="SBBX_SYHC${syhc.unid}.hcmc" name="SBBX_SYHC${syhc.unid}.hcmc" notnull="false" nullalert="" type="text" value="${syhc.hcmc}" />
</td>
<td width="150px" height="25" align="center">
<input comments="耗材数量" id="SBBX_SYHC${syhc.unid}.hcsl" name="SBBX_SYHC${syhc.unid}.hcsl" notnull="false" nullalert="" type="text" value="${syhc.hcsl}" />
</td>
<td align="center" height="25">
<a style="color:red" href="javascript:void(0);" οnclick="deletegzlb('${syhc.unid}');">删除</a>
</td>
</tr>
</c:forEach>
</table>