JSP中的EL表达式如何取值

无情 阅读:676 2021-03-31 22:25:10 评论:0


源代码:

action层:

	// 返回上傳圖片路勁 
		public ActionForward getImagePath(ActionMapping mapping, ActionForm form, HttpServletRequest request, 
				HttpServletResponse response) throws Exception { 
			// 获取顶部图片路径 
			HQLInfo tophqlInfo = new HQLInfo(); 
			tophqlInfo.setWhereBlock("imageuploadmain.isEnable=:isEnable and imageuploadmain.imageLocation=:imageLocation"); 
			tophqlInfo.setParameter("isEnable", "0");	 
			tophqlInfo.setParameter("imageLocation", "0"); 
			List top_image_list = getServiceImp(request).findList(tophqlInfo); 
			<span style="color:#ff0000;">request.setAttribute("top_image", top_image_list); 
			request.setAttribute("top_image_size", top_image_list.size());</span> 
			// 获取底部图片路径 
			HQLInfo centerhqlInfo = new HQLInfo(); 
			centerhqlInfo 
					.setWhereBlock("imageuploadmain.isEnable=:isEnable and imageuploadmain.imageLocation=:imageLocation"); 
			centerhqlInfo.setParameter("isEnable", "0"); 
			centerhqlInfo.setParameter("imageLocation", "1"); 
			List center_imagelist = getServiceImp(request).findList(centerhqlInfo); 
			<span style="color:#ff0000;">request.setAttribute("center_image", center_imagelist); 
			request.setAttribute("center_image_size", center_imagelist.size());</span> 
 
			return getActionForward("iamge", mapping, form, request, response); 
		}


jsp页面:

<ul id="slides"> 
			<% 
				List top_image_list = (List) request.getAttribute("top_image"); 
				// System.out.println("size is:"+top_image_list.size()); 
				int image_size = top_image_list.size(); 
			%> 
			<span style="color:#ff0000;">${top_image_size}</span> 
			<br> 
 
			<li 
				style="background: url(/ekp/kms/multidoc/resource/img/banner1.jpg) no-repeat center top;"><a 
				href="javascript:void(0);" target="_blank">banner1</a></li> 
			<li 
				style="background: url(/ekp/kms/multidoc/resource/img/banner2.jpg) no-repeat center top;"><a 
				href="javascript:void(0);" target="_blank">banner2</a></li> 
			<li 
				style="background: url(/ekp/kms/multidoc/resource/img/banner3.jpg) no-repeat center top;"><a 
				href="javascript:void(0);" target="_blank">banner3</a></li> 
			<li 
				style="background: url(/ekp/kms/multidoc/resource/img/banner4.jpg) no-repeat center top;"><a 
				href="javascript:void(0);" target="_blank">banner4</a></li> 
		</ul>
页面展示:




声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号