1。静态变量方式:
<!--
实现select标签回显
-->
1.<select name="curStatus" value="${curStatus}">
<option value="0">-请选择-</option>
<option value="1" <c:if test="${'1' eq curStatus}">selected</c:if> >男</option>
<option value="2" <c:if test="${'2' eq curStatus}">selected</c:if> >女</option>
</select>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
2。动态方式:两个变量都来自后台
<c:set var="schoolid" value="${pageData.SchoolId}" scope="request"/>
<select name="schoolId" id="schoolId" style=" 95%">
<option value="0">==请选择==</option>
<c:forEach items="${organizeList}" var="var" varStatus="vs">
<option value="${var.name_code}" <c:if test="${var.name_code==schoolid}">selected</c:if> > ${var.name}</option>
</c:forEach>
</select>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
说明一下:若是想2那种,实质上是比较两个对象的属性值,不能写成如下:
<select name="schoolId" id="schoolId" style=" 95%">
<option value="0">==请选择==</option>
<c:forEach items="${organizeList}" var="var" varStatus="vs">
<option value="${var.name_code}" <c:if test="${var.name_code==pageData.SchoolId}">selected</c:if> > ${var.name}</option>
</c:forEach>
</select>
转载自http://blog.csdn.net/xinghuo0007/article/details/53381085