我有一个JSP对象列表,并希望基于单击的超链接将值发送回servlet。我的代码显示在下面。从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
非常好看,这样的答案是为什么SO如此之大。 – 2013-04-06 23:13:32
对不起,这是一个错字,并没有这不与“得到”(我已编辑的原始帖子) – 2013-04-06 23:20:52
@Jigar我也有类似的问题[这里](http://stackoverflow.com/questions/22368770/how-to-iterate-an-object-in-jsp-to-get-the-percentage)。看看你能帮助我吗?任何帮助将不胜感激..感谢您的帮助。 – AKIWEB 2014-03-13 04:36:01