分页的使用

来源:互联网 发布:java记事本程序设计 编辑:程序博客网 时间:2024/05/16 05:13

1.添加页面的规范使用

<%--  Created by IntelliJ IDEA.  User: zhangxiaohu  Date: 2017/8/11  Time: 10:39  To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%--加上这段java代码 --%><%    String path = request.getContextPath();    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;%><html><head>    <title>欢迎</title>    <script src="/resources/jquery/jquery-1.8.3.js"></script>    <script type="text/javascript">        $(function () {            $("#houseName").blur(function() {                $("#s2").empty();                houseName=$(this).val();                if(houseName==null||houseName==""){                    $("#s2").html("房产名称不可为空!");                }else {                    $.ajax({                        type:"post",                        url:"${pageContext.request.contextPath }/house/selHouseByName.action",                        data:{                            houseName:houseName                        },                        dataType:"json",                        success:function (data) {                            if(data.flag==1){                                alert("用户名可用!");                            }else {                                alert("用户名不可用,用户名不能重!");                            }                        },                        error:function () {                            alert("系统繁忙,请稍候再试!");                        }                    });                }            });        });    </script></head><body><p2>添加页面</p2><br/><form action="/house/addHouse.action" enctype="multipart/form-data" method="post">房产名称: <input type="text" name="houseName" id="houseName" /><span id="s2"></span><br/>房产图片 :<input type="file" name="file"/><br/>房产单价 : <input type="text" name="housePrice" id="housePrice" /><br/>房产面积 : <input type="text" name="houseArea" id="houseArea" /><br/>所属户主 : <select name="personId">    <option value="">请选择</option>    <c:forEach items="${sessionScope.holderNameList}" var="customer">        <option value="${customer.id}">${customer.holderName}</option>    </c:forEach></select><br/>    <input type="submit" value="注册"/></form></body></html>


2.项目的展示分页

<%--  Created by IntelliJ IDEA.  User: zhangxiaohu  Date: 2017/8/11  Time: 10:39  To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %><%--加上这段java代码 --%><%    String path = request.getContextPath();    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;%><html><head>    <title>欢迎</title>    <script src="/resources/jquery/jquery-1.8.3.js"></script>    <script>        function checkAll() {            $("input[id='features2']").each(                function () {                    if($(this).prop("checked")){                        $(this).removeAttr("checked");                    }else {                        $(this).prop("checked","true");                    }                });        }        function batchHouse() {            var checkedNum = $("input[name='features']:checked").length;            if(checkedNum == 0) {                alert("请选择至少一项!");                return;            }            if(confirm("确定要删除所选项目?")) {                var checkedList=[];                $("input[name='features']:checked").each(function () {                    checkedList.push($(this).val());                });                ids=checkedList.toString();                $.ajax({                    type:"post",                    url:"/house/delBatchHouse.action",                    data:{                        ids:ids                    },                    dataType:"json",                    success:function (data) {                        alert(data.flag);                        location.href="/house/findAllHouse.action";                    },                    error:function () {                        alert("出现错误,稍后再试!");                    }                });            }        }    function person() {    var personId=$("#personId").val();        $.ajax({            type:"post",            url:"/house/findPerson.action",            data:{                holderName:personId            },            dataType:"json",            success:function (data) {                    alert(data.flag2);                    location.href="/house/fuzzyHouseAll.action";            },            error:function () {                alert("出现错误,稍后再试!");            }        });    }    </script></head><body><p2>展示页面</p2><br/><form action="/house/findHouseAll.action" method="post">    模糊查询房产名:<input type="text" name="houseName"/>    <input type="submit" value="搜索"/></form>    <a href="/house/selHolder.action">添加房屋信息</a><input type="button" value="全选/全不选" id="hide" onclick="checkAll()"/><input type="button" value="批量删除" onclick="batchHouse()"/>    根据户主名查询:<select name="personId" id="personId" onchange="person()">    <option value="">请选择</option>    <c:forEach items="${sessionScope.holderNameList}" var="customer">        <option value="${customer.holderName}">${customer.holderName}</option>    </c:forEach></select><br/><table border="1">    <tr>        <td>复选框</td>        <td>房产id</td>        <td>房产名称</td>        <td>房产图片</td>        <td>房产面积</td>        <td>房产单价</td>        <td>房产总价</td>        <td>所属户主</td>        <td>购买日期</td>        <td>操作</td>    </tr>    <c:forEach items="${houseList}" var="house">        <tr>            <td> <input type="checkbox" id="features2" name="features" value="${house.id}"/></td>            <td> ${house.id}</td>            <td>${house.houseName}</td>            <td><img src="${house.houseImg}"/></td>            <td>${house.houseArea}</td>            <td>${house.housePrice}</td>            <td>${house.houseTotal}</td>            <td>${house.holderName}</td>            <td><f:formatDate value="${house.buyDate }" pattern="yyyy-MM-dd HH:mm:ss"/></td>            <td>                <a href="/house/selHouseById.action?id=${house.id}">修改</a>                <a href="/house/delHouse.action?id=${house.id}">删除</a>            </td>        </tr>    </c:forEach></table>    <br/><form action="/house/findHouseAll.action" method="post">    输入起始页:<input type="text" name="begin"/>     输入每页的条数: <input type="text" name="pageSize"/><br/>    <input type="submit" value="查询"/></form></body></html>


原创粉丝点击