从另一个jsp中将jsp中的列表值作为request.getParameter(“”)获取
a.jsp
List<String> abc =
(ArrayList<String>)request.getAttribute("studentsrollno");// got
studentsrollno from servlet by request.setAttribute();
<form action="b.jsp" method="post">
<input type="hidden" name="rollno" value="<%=abc%>"/>
<input type="submit">
</form>
b.jsp
<%
List<String> a2 = (ArrayList<String>) request.getParameter("rollno");//
getting error string cannot be converted to ArrayList<String> // How can I
display data rollno here ?
// Iterator<String> itr = a2.iterator();
%>
非常感谢
答案 0 :(得分:1)
您可以将值检索为数组:
String[] vals = request.getParameterValues("rollno");
这些值应作为单独的表单参数发出:
<c:foreach items="${abc}" var="item">
<input type="hidden" name="rollno" value="${fn:escapeXml(item)}" />
</c:foreach>