這裏是我的代碼,我怎麼能留住形式的值時,我的超級引用鏈接上單擊(A HREF:代碼的底部)。如何在jsp頁面中保留表單值?
<form action="APPServlet">
<div class="">
<div class="">Search For:</div>
<div class="">
<input type="text" size="45" align="right" name="searchRequest">
</div>
</div>
<div class="">
<div class="">Exclude:</div>
<div class="">
<input type="text" size="45" align="right" name="excludeWords">
</div>
</div>
<div class="">
<div class="">In Modules:</div>
<div class="">
<select name="modules">
<option name="module" value="all">All modules</option>
<c:forEach var="module" items="${modelObj.modules}">
<option name="module" value="${module}">${module}</option>
</c:forEach>
</select>
</div>
</div>
</form>
<!-- ahref outside the form , this does not work
&searchRequest=${searchRequest} <- Guess the value is out of scope
-->
<div class="div-table-row">
<div class="div-table-single-col">
${question.id} <a href="APPServlet?id=${question.id}&searchRequest=${searchRequest}">${question.topic}</a>
</div>
</div>
您可以簡單地將'value'屬性添加到這些文本框中:'value = $ {param.serchRequest}'和'value =「$ {param.excudeWords}」'。一定要將它們作爲參數傳遞給查詢字符串,因爲您正在使用該鏈接。如果我是你,那麼我會更多地使用支持bean來達到這個目的。 – Lion 2013-03-03 15:31:10