jsp頁面的select下拉框的代碼:
<select class="chzn-select" name="select" id="select" style="vertical-align:top;width: 120px;">
<option value="">全部</option>
<option value="name" <c:if test="${'name' eq pd.select}">selected</c:if> >姓名</option>
<option value="age" <c:if test="${'age' eq pd.select}">selected</c:if> >年齡</option>
<option value="sex" <c:if test="${'sex' eq pd.select}">selected</c:if> >性別</option>
</select>
後臺代碼Controller或者servlet內只需要將搜索時選擇的選項重新保存至pd中就行了。
將select的value值保存在pd中然後將pd發送至view
Controller中:
mv.addObject("pd", pd);
servlet中:
request.setattiute("pd",pd);