日期:2014-05-16 浏览次数:20430 次
From:http://www.abc188.com/info/html/chengxusheji/Javajishu/20080225/46194.html
本文将向大家讲述如何通过sun公司的jstl标签来访问list对象,并在JSP页面进行显示
一般而言,list对象会存储在request对象,session对象中,一般采用框架(比如说Struts框架中的Action)完成把list对象置入request对象中,
XXAction{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
/*从session中获得用户信息*/
HttpSession session=request.getSession();
User user =(User)session.getAttribute("user");
request.setAttribute("user",user);
/*建立rolelist*/
List rolelist =new ArrayList();
for(int i=0;i<5;i ){
Role role= new Role(i,"role" i);
rolelist.add(role);
}
request.setAttribute("role_list",rolelist);
}
本文的讲解重点是jstl标签部分: