<%@ page import="com.tianbo.util.dao.Page" %><%--
  Created by IntelliJ IDEA.
  User: 烽
  Date: 2015/7/11
  Time: 19:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <title>Msg</title>
    <script src="/js/common/jquery.js" type="text/javascript"></script>
    <script src="/js/common/ajax.js" type="text/javascript"></script>
</head>
<body>
<h1>Msg</h1>
<table>
    <tr>
        <th>序号</th>
        <%--<td>${msg.fid}</td>--%>
        <th>消息类型</th>
        <th>发送者</th>
        <th>类型</th>
    </tr>
    <c:set var="page" value="${map.get('page')}"></c:set>
    <c:forEach items="${map.get('list')}" var="msg" varStatus="num">
        <tr>
            <td>${(num.index+1)+(page.getCurrent()-1)*page.getLength()}</td>
            <%--<td>${msg.fid}</td>--%>
            <td>${msg.messtype}</td>
            <td>${msg.sndr}</td>
            <td>${msg.type}</td>
        </tr>
    </c:forEach>

</table>

共${page.getTotal()}页,共${page.getCount()}条数据,当前第${page.getCurrent()}页,每页${page.getLength()}条
<div>
    <c:set var="endPage" value="false" />
    <c:forEach begin="0" step="1" end="${page.getTotal()-1}" var="everyPage">
        <c:choose>
            <c:when test="${everyPage+1 >10}">
                <c:if test="${endPage=='false'}">
                    <label>......</label>
                    <c:set var="endPage" value="true" />
                </c:if>
            </c:when>
            <c:otherwise>
                <a href="/msg/list?page.begin=${everyPage*page.length}">${everyPage+1}</a>
            </c:otherwise>
        </c:choose>
    </c:forEach>
    <a href="/msg/list?page.begin=${(page.getTotal()-1)*page.length}">${page.getTotal()}</a>
    转到第<input type="text" name="turnPage" id="turn2page"><button onclick="turn2page();">确定</button>
</div>

<script type="text/javascript">

    function turn2page(){
        var pageVal =   $("#turn2page").val();
        var pageBegin = (pageVal-1)*${page.length};
        var url="/msg/list";
        var para = {"page.begin":+pageBegin};

        handleAjax(url,para,"post","","").done(function(resp){

            alert(resp);

        }).fail(function(err){
            alert(err);
        });
    }

</script>
</body>
</html>