将列表传递到另一个jsp文件 [英] Pass a List to another jsp file

查看:105
本文介绍了将列表传递到另一个jsp文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将主JPS中的List类型对象传递给一个include JSP(jsp:include).由于parm仅支持字符串,因此无法使用parm标记将列表类型数据传递给包含文件.

I wanted to pass a List type object which is in the main JPS to an include JSP ( jsp:include). Since the parm only support strings, I cannot use the parm tag to pass List type data to the include file.

使用示例:

<jsp:include page="/jsp/appList.jsp">
     <jsp:param name="applications" value="${applications}"/>
</jsp:include>

或者:

<jsp:include page="/jsp/appList.jsp">
     <jsp:param name="applications" value="${confirmed_applications}"/>
</jsp:include>
<jsp:include page="/jsp/appList.jsp">
    <jsp:param name="applications" value="${unconfirmed_applications}"/>
</jsp:include>
<jsp:include page="/jsp/appList.jsp">
    <jsp:param name="applications" value="${canceled_applications}"/>
</jsp:include>

我可以创建一个简单标记处理程序,但是我想知道是否有更简单的方法.

I could create a Simple Tag Handler but I would like to know if there is an easier way.

推荐答案

与ChssPly76达成一致,如果在JSP中生成列表,则可能是麻烦的征兆,但将对象获取到另一个JSP的另一种替代方法是使用脚本将其添加到HttpServletRequest对象属性字段中:

Agree with ChssPly76 that its probably a sign of trouble if the List is being generated in the JSP, but another alternate approach to get the object to the other JSP is to add it to the HttpServletRequest objects attribute field using a scriplet:

带有列表的JSP:

<%
request.setAttribute("theList", ListObject);
%>

另一个JSP:

<%
List myList = (List) request.getAttribute("theList");
%>

这篇关于将列表传递到另一个jsp文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆