<form role="form" action="${pageContext.request.contextPath }/emp/reg" method="post">
<div class="form-group">
<label for="name">姓名</label> <input type="text" class="form-control"
name="ename" id="name" placeholder="请输入姓名">
</div>
<div class="form-group">
<label for="name">级别</label> <input type="text" class="form-control"
name="level" id="level" placeholder="请输入级别">
</div>
<div class="form-group">
<label for="inputEmail" class="col-sm-2 control-label">所属部门</label>
<div class="col-sm-3">
<select class="form-control" name="department.did">
<c:forEach items="${list }" var="de">
<option value="${de.did }">${de.dname }</option>
</c:forEach>
</select>
</div>
</div>
<button type="submit" class="btn btn-default">注册</button>
</form>
2.循环遍历
<div class="row">
<div class="col-md-10 col-md-offset-1">
<table class="table table-hover">
<tr>
<td><input type="checkbox" id="special" class="checkeids" οnclick="checkall()"></td>
<td>id</td>
<td>姓名</td>
<td>级别</td>
<td>所属部门</td>
<td>操作</td>
</tr>
<c:forEach items="${list }" var="u">
<tr>
<td><input type="checkbox" class="common" value="${u.eid }"></td>
<td>${u.eid }</td>
<td>${u.ename }</td>
<td>${u.level}</td>
<td>${u.department.dname}</td>
<td style="display:none">${u.department.did }</td>
<td>
<a class="btn btn-default" href="${pageContext.request.contextPath }/emp/delbyeid?eid=${u.eid }" role="button">删除</a>
<a class="btn btn-default" href="${pageContext.request.contextPath }/emp/selectbyeid?eid=${u.eid }" role="button">修改</a>
</td>
</tr>
</c:forEach>
</table>
</div>
</div>
3.修改
<form role="form" action="${pageContext.request.contextPath }/emp/update" method="post">
<div class="form-group">
<label for="name">姓名</label> <input type="text" class="form-control"
name="ename" id="name" value="${em.ename }" placeholder="请输入姓名">
</div>
<div class="form-group">
<label for="name">级别</label> <input type="text" class="form-control"
name="level" id="level" value="${em.level }" placeholder="请输入级别">
</div>
<div class="form-group">
<label for="inputEmail" class="col-sm-2 control-label">所属部门</label>
<div class="col-sm-3">
<select class="form-control" name="em.department.did">
<c:forEach items="${list }" var="de">
<option value="${de.did }" <c:if test="${de.did==em.department.did }">selected="selected"</c:if>>${de.dname }</option>
</c:forEach>
</select>
</div>
</div>
<button type="submit" class="btn btn-default">保存</button>
</form>