[英]passing string array as hidden value from one jsp to another jsp
I am trying to pass String array from one jsp to another. 我试图将String数组从一个jsp传递到另一个。 I am using JSTL in my JSP. 我在JSP中使用JSTL。 In my first JSP i am doing like this 在我的第一个JSP中,我这样做
<c:if test="${fn:length(empBean.additionalEmailAddr) gt 0}">
<c:forEach begin="0" end="${fn:length(empBean.additionalEmailAddr) - 1}" var="ind" >
<input type="hidden" name="inbdAdditionalEmailAddr" value="${empBean.additionalEmailAddr[ind]}"/>
</c:forEach>
</c:if>
and trying to access the values in another jsp as follows 并尝试如下访问另一个jsp中的值
<%
String[] inbdAddEmlAddr = request.getParameter("inbdAdditionalEmailAddr");
%>
and i am planning to use JSTL to print the array values. 我正计划使用JSTL打印数组值。
In the second jsp i am getting type mismatch error. 在第二个jsp中,我收到类型不匹配错误。 Please help. 请帮忙。
Is this the right approach ? 这是正确的方法吗? Any help is appreciated 任何帮助表示赞赏
Thanks 谢谢
request.getParameter()
returns a String
which the code attempts to assign to a String[]
, causing the exception. request.getParameter()
返回一个String
,代码尝试将其分配给String[]
,从而导致异常。
Use request.getParameterValues('inbdAdditionalEmailAddr');
使用request.getParameterValues('inbdAdditionalEmailAddr');
to retrieve parameters as an array. 以数组形式检索参数。
See the documentation . 请参阅文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.