我在 JSP 中有一个对象列表,并希望根据单击的超链接将值发送回 servlet。我的代码如下所示。
<body>
<h1>Choose a Festival</h1>
<jsp:useBean id="allFestivals" type="java.util.ArrayList" scope="session" />
<table border ="1">
<tr>
<td>Festival Name:</td>
<td>Location:</td>
<td>Start Date:</td>
<td>End Date:</td>
<td>URL:</td>
<td>List of Trips to </td>
</tr>
<c:forEach items="${allFestivals}" var="allFestivals">
<tr>
<td>${allFestivals.festivalName}</td>
<td>${allFestivals.location}</td>
<td>${allFestivals.startDate}</td>
<td>${allFestivals.endDate}</td>
<td>${allFestivals.URL}</td>
<td>
//THE ISSUE IS IN THIS FORM, I SUPPOSE SYNTAX ISSUE
<form name="linkChecker" method="get" action="ControllerServlet">
<input type = "hidden" value="${allFestivals.ID}" name="festivalProfileLink" />
<a HREF ="javascript:document.linkChecker.submit()">View Related Trips</a>
</form>
</td>
</tr>
</c:forEach>
</table>
<a href="logout.jsp">Logout</a>
</body>
和 servlet GET 方法:
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String aa = request.getParameter("festivalProfileLink");
JOptionPane.showMessageDialog(null, aa);
if("hello".equals(aa)) {
JOptionPane.showMessageDialog(null, "dfgdfgdf");
}
}
目前没有信息(或至少没有价值)被发送到 servlet