admin체크, 구현클래스 처리
if(session.getAttribute("userid")==null)
return "redirect:/login/login";
if(session.getAttribute("userid").equals("admin"))
{
// 페이지관련
// 1. limit에 사용될 해당 페이지의 시작 인덱스
int page;
if(request.getParameter("page")==null)
{
page = 1;
}
else
{
page = Integer.parseInt(request.getParameter("page"));
}
int index = (page-1)*20;
int pstart = page/10;
if(page%10==0)
pstart=pstart-1;
// pstar,pend,chong 구하기
pstart = pstart*10+1;
int pend = pstart+9;
int chong = mapper.getChong();
if(pend>chong)
pend=chong;
model.addAttribute("page",page);
model.addAttribute("pstart",pstart);
model.addAttribute("pend",pend);
model.addAttribute("chong",chong);
html
</c:forEach>
<tr>
<td colspan="8" align="center">
<c:if test="${pstart != 1}">
<a href="adminproduct?page=${pstart-1}"> << </a>
</c:if>
<c:if test="${pstart == 1}">
<<
</c:if>
<c:if test="${page != 1}">
<a href="adminproduct?page=${page-1}"> < </a>
</c:if>
<c:if test="${page == 1}">
<
</c:if>
<c:forEach begin="${pstart}" end="${pend}" var="i">
<c:if test="${page != i}">
<a href="adminproduct?page=${i}"> ${i} </a>
</c:if>
<c:if test="${page == i}">
<a href="adminproduct?page=${i}" style="color:red"> ${i} </a>
</c:if>
</c:forEach>
<c:if test="${page != chong}">
<a href="adminproduct?page=${page+1}"> > </a>
</c:if>
<c:if test="${page == chong}">
>
</c:if>
<c:if test="${pend != chong}">
<a href="adminproduct?page=${pend+1}"> >> </a>
</c:if>
<c:if test="${pend == chong}">
>>
</c:if>
</td>
</tr>
chong 구하기
<select id="getChong" resultType="int">
select ceil(count(*)/20) from product;
</select>