<script type="text/javascript"> function submitMessageForm(flag) { if ('first' == flag) { document.getElementById('page').value = 1; } else if ('pre' == flag) { var current = Number(document.getElementById('page').value); if (current > 1) { document.getElementById('page').value = current - 1; } } else if ('next' == flag) { var current = Number(document.getElementById('page').value); var last = Number(document.getElementById('last').value); if (current < last) { document.getElementById('page').value = current + 1; } } else if ('last' == flag) { var last = Number(document.getElementById('last').value); document.getElementById('page').value = last < 1 ? 1 : last; } document.getElementById('messageForm').submit(); } </script>
<div id="pagefy"> <ul> <form id="messageForm" action="${pageContext.request.contextPath}/message/list.do" method="post"> <input type="hidden" id="page" name="page" value="${page}"> <input type="hidden" id="last" name="last" value="${last}"> <li><a href="javascript:void(0)" onclick="submitMessageForm('first')">首页</a></li> <li><a href="javascript:void(0)" onclick="submitMessageForm('pre')">上一页</a></li> <li><a href="javascript:void(0)">当前第${page}页</a></li> <li><a href="javascript:void(0)" onclick="submitMessageForm('next')">下一页</a></li> <li><a href="javascript:void(0)" onclick="submitMessageForm('last')">尾页</a></li> </form> </ul> </div>