将List从Servlet传递给JSP [英] Passing a List from Servlet to JSP
本文介绍了将List从Servlet传递给JSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试将Servlet中列表的值设置为会话变量并像JSP一样访问它时,
When I try to set the value of a list in Servlet to a session variable and access it JSP like,
doGet
HttpSession session = request.getSession(true);
session.setAttribute("MySessionVariable", authorizeUserList);
JSP
<%List lst = session.getAttribute("MySessionVariable");%>
我在JSP中收到错误,因为List无法解析为类型
I get an error in JSP as "List cannot be resolved to a type"
那我该怎么做呢?我想将一个列表从Servlet传递给JSP并填充一个Drop down。
So how should I do this? I want to pass a list from Servlet to JSP and populate a Drop down.
推荐答案
您是否导入列表并进行投射?
Are you importing list and casting?
<%@page import="java.util.List"%>
<% List lst = (List) session.getAttribute("MySessionVariable"); %>
这篇关于将List从Servlet传递给JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文