我是jstl的新手,我需要帮助在jsp上获取url-string参数,该参数还包含从数据库中检索的迭代对象列表中的EL标记.有人可以告诉我如何修复下面的代码,以便下面的代码行填充一个实际的数字
<a href="create-course-summary?spid="${param.spid}>add</a>
这是背景:
我用以下url模式调用servlet:
view-course-summaries?spid=1
这将在servlet中调用以下doGet方法:
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String spidString = req.getParameter("spid"); Long spid = new Long(spidString); List<CourseSummary> coursesummaries = new CourseSummaryDAO().findAllCS(spid); req.setAttribute("coursesummaries", coursesummaries); jsp.forward(req, resp); }
并返回以下jsp:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ include file="admintop.inc" %> <table> <tr> <td>Name of School (Course Provider):</td> <td>will go here</td> </tr> <tr><td colspan=2> <a href="create-course-summary?spid="${param.spid}>add</a> </td> </tr> <tr> <td colspan=2> <table> <tr> <th>Type</th> <th>Number</th> <th>id</th> </tr> <c:forEach varStatus="loopCounter" items="${coursesummaries}" var="coursesummary"> <tr> <td> <c:out value="${coursesummary.coursetype}" /> </td> <td> <c:out value="${coursesummary.numunits}" /> </td> <td> <c:out value="${coursesummary.id}" /> </td> </tr> </c:forEach> </table> </td> </tr> </table> <%@ include file="adminbottom.inc" %>试试这个
<a href='create-course-summary?spid=${param["spid"]}'>add</a>