Using an EL expression to achieve Product List

The principle: EL obtain the value of the domain. Product List traversed by forEach


通过<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

Import tab, c denotes a variable property

Then <c: = "$ {list}" forEach var = "item" items> Get Request domain value list

Gets the value of the current directory: <c: set var = "ctx" value = "$ {pageContext.request.contextPath}"> </ c: set>

Specific code to achieve the following:

<!--使用一个大盒子存放一个个小盒子-->
<div class="bigbox">
    <c:forEach var="item" items="${list}">
        <!--使用一个小盒子存放一个商品信息-->
		<div class="window">
        <!--存放图片的盒子-->
			<div class="imageContainer">
				<span class="imgLink">
            <!--通过变量item获取商品信息-->
				<img src="${item.imgUrl}"/>			
				</span>
				</div>
			<div class="info">
			
		<p class="price">
				<span class="pricedetail">
				¥
				<strong>${item.price }</strong>
				</span>
				<span class="postalicon">包邮</span>
				
				</p>
				
				<span class="title" title="${item.category}">${item.productName}</span>
				
				<p class="shopName">
				
				<span class="shopNick">${item.shopName }</span>
				
				<span class="payNum">${item.num }人付款</span>
				</p>
			</div>
		</div>
    </c:forEach>
</div>

 

Published 10 original articles · won praise 11 · views 598

Guess you like

Origin blog.csdn.net/weixin_44715643/article/details/103915339