---
# System prepended metadata

title: 前台改成商品

---

# 前台改成商品
```
<%
//得到已追蹤的商品
	Product_favService prod_favsvc = new Product_favService();
	List<Product_favVO> listfav = prod_favsvc.getOnePf(stuno);
	pageContext.setAttribute("listfav", listfav);
//得到正在促銷的專案
	Sale_projectService saleSvc = new Sale_projectService();
	List<Sale_projectVO> sapro_list = saleSvc.getAllfilter();
	pageContext.setAttribute("sapro_list", sapro_list);
//得到正在促銷的商品
	List<Sale_projectVO> Sale_projectVO_list = saleSvc.getAllfilter();
	Map<String, String>  salemap = new HashMap<>();
	Sale_listService sale_listSvc = new Sale_listService();
	List <Sale_listVO> sale_list = null;
	for(Sale_projectVO  Sale : Sale_projectVO_list){
		sale_list = sale_listSvc.getOneSl(Sale.getSapro_no());
		for(Sale_listVO  Salelist : sale_list){
			salemap.put(Salelist.getProdno(),String.valueOf(Salelist.getSapro_price()));
		}
	}
	pageContext.setAttribute("salemap", salemap);
%>

							 <div class="col-12 col-sm-3 col-lg-4">
									<div class="single-product-wrapper">
										<div class="product-img">
											<a href="<%=request.getContextPath()%>/Shopping.html?action=getOne_For_Display&prodno=${productVO.prodno}" id="titilea">
											<img src="<%= request.getContextPath()%>/product/product.pic?prodno=${productVO.prodno}" alt=""></a>
											<!-- Product Badge -->
											<!-- Favourite -->
											<form
												action="<%=request.getContextPath()%>/back-end/product/product_fav.html"
												method="post">

												<div class="product-favourite">
													<button class="favme fa fa-heart" type="submit"  
													<c:forEach var="product_fav_vo" items="${listfav}">
													<c:if test="${product_fav_vo.prodno == productVO.prodno}">value="Disabled" disabled  title="此商品已加入追蹤" </c:if>
													</c:forEach>>
													</button>
													<input type="hidden" name="prodno" value="${productVO.prodno}"> 
													<input type="hidden" name="stuno" value="${stuno}"> 
													<input type="hidden" name="action" value="insert">
													<input type="hidden" name="requestURL" value="<%=request.getServletPath()%>"> 
													<input type="hidden" name="whichPage" value="<%=whichPage%>">
												</div>
											</form>
										</div>

										<!-- Product Description -->
										<div class="product-description">
											<a
												href="<%=request.getContextPath()%>/Shopping.html?action=getOne_For_Display&prodno=${productVO.prodno}"
												id="titilea">${productVO.prodname}</a>

										<c:forEach var="saleitems" items="${salemap}" >
										 <c:if test="${saleitems.key == productVO.prodno}"> 
										<p class="product-price sale">${saleitems.value}</p>

										</c:if>

										</c:forEach>
										<p class="product-price">${productVO.prodprice}</p>


<c:if test="${saleitems.key == productVO.prodno}"> <p class="product-price">${saleitems.value}</p></c:if>
<%-- 				<c:forEach var="saleitems" items="${salemap}" ><c:if test="${saleitems.key == productVO.prodno}"> <p class="product-price">${productVO.prodprice}</p></c:if></c:forEach> --%>
																							<!-- Hover Content -->
											<div class="hover-content">
												<!-- Add to Cart -->
												<div class="add-to-cart-btn">
													<a href="#" class="btn essence-btn addtocart">Add to
														Cart</a> <input type="hidden" value="${productVO.prodno}">
												</div>

											</div>
										</div>
									</div>
								</div>

							</c:forEach>
						</div>
```