赞
踩
三级联动点击省份出现市区点击市区出现区域
动态sql的模糊查询
数据库表:数据需要评论1
TAddressCityMapper接口
TAddressProvinceMapper接口
int deleteByPrimaryKey(Integer id);
int insert(TAddressProvince record);
TAddressProvince selectByPrimaryKey(Integer id);
int updateByPrimaryKey(TAddressProvince record);
List<TAddressProvince> queryAll();
TAddressTownMapper接口
List<TAddressTown> queryByName(@Param("cCode")Integer cCode);
TAddressCityMapper.xml
TAddressProvinceMapper.xml
TAddressTownMapper.xml
service层掉下就行了
修改页面
<form th:action="@{/chain/upda}" th:method="post"> <div style="width: 450px;height:100%; margin:0px auto"> <h1 style="color:red">修改页面</h1> <table border="2px"> <input type="hidden" th:name="id" th:value="${tAddressProvince.id}"> <tr> <td>省份编号</td> <td><input type="text" th:name="code" required th:value="${tAddressProvince.code}"></td> </tr> <tr> <td>省份</td> <td><input type="text" th:name="name" required th:value="${tAddressProvince.name}"></td> </tr> <td>操作</td> <td><input th:type="submit" th:value="修改"><a th:href="@{/chain/list}" style="text-decoration: none"> 返回</a></td> </tr> </table> </div> </form>
allList页面
<script src="http://code.jquery.com/jquery-latest.js"></script> <body> <div style="width: 680px;height:100%; margin:0px auto"> <form th:action="@{/chain/list}" method="get"> 所属省份: <select th:name="pName" id="pName"> <option th:value="${p.code}" th:each="p:${tAddressProvinces}" th:text="${p.name}"></option> </select> 所属市区: <select th:name="cName" id="cName"> <option value=""></option> </select> 所属地区: <select th:name="tName" id="tName"> <option value=""></option> </select> <input type="submit" th:value="查询" id="query"> <a type="button" th:href="@{/chain/add}" style="text-decoration: none">添加</a> </form> <table border="2px"> <thead> <tr> <th>省份</th> <th>相关操作</th> </tr> </thead> <tbody> <tr th:each="list:${tAddressProvinces}"> <td th:text="${list.name}"></td> <td> <a th:href="@{/chain/del/(id=${list.id})}">删除</a> <a th:href="@{/chain/upd/(id=${list.id})}">编辑</a> </td> </tr> </tbody> </table> <table border="2px"> <thead> <tr> <th>省份</th> <th>市区</th> <th>区域</th> </tr> </thead> <!--这里的数据要从servlet里面获取--> <tbody> <tr th:each="list:${tAddressCities}"> <td th:text="${list.TAddressProvince.name}"></td> <td th:text="${list.name}"></td> <td th:text="${list.TAddressTown.name}"></td> </tr> </tbody> </table> </div> </body> <script> $("#pName").change(function (){ var pCode=$("#pName").val(); $.ajax({ url:"/chain/getCity/"+pCode, type:"get", dataType:"json", success:function (data){ //情空重复数据 $("#cName").empty(); for (var i=0;i<=data.length;i++){ $("#cName").append("<option value='"+data[i].code+"'>"+data[i].name+"</option>") } } }) }) $("#cName").change(function (){ var cCode=$("#cName").val(); $.ajax({ url:"/chain/getTown/"+cCode, type:"get", dataType:"json", success:function (data){ $("#tName").empty(); for (var i=0;i<=data.length;i++){ $("#tName").append("<option value='"+data[i].code+"'>"+data[i].name+"</option>") } } }) }) </script>
新增页面
<form th:method="post" th:action="@{/chain/addp}"> <div style="width: 450px;height:100%; margin:0px auto"> <h1 style="color: aquamarine">新增</h1> <table border="2px"> <tr> <td>省份编号</td> <td><input type="text" th:name="code" required></td> </tr> <tr> <td>省份</td> <td><input type="text" th:name="name" required></td> </tr> <tr> <td>相关操作</td> <td><input th:type="submit" th:value="新增"/><a th:href="@{/chain/list}" style="text-decoration: none"> 返回</a></td> </tr> </table> </div> </form>
有什么问题的可以评论私信
源码需要口1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。