jstl--从内置域中选中当前用户下拉框状态 ${o.id eq user.id ? "selected" : ""}

demo1:

下拉框:

request域中数据

{"ownerList":[{"id":"1","username":"张三"},{"id":"2","username":"1111"},{"id":"3","username":"王五"}]}

已知当前登录用户user.id=1

html中jstl代码:

<select class="form-control" id="edit-transactionOwner">

     <c:forEach items="${ownerList}" var="o">

       <option value="${o.id}"  ${o.id eq user.id ? "selected" : ""}>${o.username}</option>

     </c:forEach>

</select>

猜你喜欢

转载自blog.csdn.net/tanganq/article/details/81264417