Mybatis
쿼리문 Mapping
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="ShopDAO">
<!-- 칼럼명과 VO 이름이 다를때 맵핑을 따로 잡아준다 -->
<resultMap type="shop" id="shopResult">
<id property="productId" column="PRODUCT_ID"/>
<result property="productName" column="product_name"/>
<result property="productPrice" column="product_price"/>
<result property="productDesc" column="product_desc"/>
<result property="productImgStr" column="product_img"/>
</resultMap>
<select id="SELECT_ALL_TOP" parameterType="shop" resultMap="shopResult">
SELECT * FROM tbl_product WHERE product_id Between 10021 And 10039 order by product_id desc
</select>
</mapper>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ include file ="/include/top.jsp" %>
<section>
<br>
<div align="center">
<h2>Top10 상품</h2>
<table border="1" width="600">
<c:forEach items="${li}" var="m" varStatus="status">
<c:if test="${status.index % 5 == 0}">
<tr>
</c:if>
<td align="center">
순위 : ${status.index+1}위
<img src="<%=path %>/shop/files/${m.productImgStr}" width="100" height="100">
가격: ${m.productPrice}
</td>
<c:if test="${status.index % 5 == 4 || status.last}">
</tr>
</c:if>
</c:forEach>
</table>
</div>
</section>
<%@ include file="/include/footer.jsp" %>
배열값의 index를 활용해 5개씩 2행의 테이블을 작성했다.