<c:forEach var="it" items="${sessionScope.projDetails}">
<tr>
<td>${it.pname}</td>
<td>${it.pID}</td>
<td>${it.fdate}</td>
<td>${it.tdate}</td>
<td> <a href="${it.address}" target="_blank">Related Documents</a></td>
<td>${it.pdesc}</td>
<form name="myForm" action="showProj">
<td><input id="button" type="submit" name="${it.pID}" value="View Team">
</td>
</form>
</c:forEach>
参考上面的代码,我从某个servlet获取会话对象projDetails
,并在JSP中显示其内容。由于数组列表projDetails
具有多个记录,所以字段pID
也假定不同的值,并且显示将是具有许多行的表格。
现在我想调用一个servlet showProj
当用户点击“查看团队”(将在每行)基于该行的“pID”。 有人能让我知道如何将用户点击JSP的特定pID
传递给servlet吗?如何将会话值作为请求参数从JSP传递到servlet?
我尝试了上面的代码,但它说:“所请求的资源不可用”,甚至船尾呃提供servlet的完整URL,我怀疑我们是否通过JSP中的“href”访问servlet? – Vinod
你当然可以通过常规的''. My first thought is that you haven't set up a '' in your web.xml. There are a number of questions on SO that deal with this, or see "Servlet Basics" in the second link I provided above, which deals with "Giving URLs to Servlets" –
kaveman
It works now, i just put a "." in Vinod