zoukankan      html  css  js  c++  java
  • 模糊查询

    js页面

    $('.layui-btn').click(function () {
    var inputVal = $('.layui-input').val()
    table.reload('bookReload', {
    url: '/stu/findStu'
    ,where: {
    stuname : inputVal
    }
    });
    })
    Html页面
    <div class="demoTable">
    搜索:
    <div class="layui-inline">
    <input class="layui-input" name="keyword" id="demoReload" autocomplete="off">
    </div>
    <button class="layui-btn" data-type="reload">搜索</button>
    </div>
    (注:将搜索框放在table的上方,也就是body的第一行)

    后台
      在全查询的基础上加上模糊搜索的参数(比如:根据name模糊搜索,就加上name这个参数)
    Service层
    public JsonData findStu(String stuname) {
    if (stuname==null){
    stuname="%%";
    }else {
    stuname="%"+stuname+"%";
    }
    List<Student> stu = stuMapper.findStu(stuname);
    return JsonData.buildSuccess(stu);
    }
    mapper.xml
      sql语句:
    SELECT t.*, s.username,s.pwd,s.stuname,s.sex,s.status FROM temperature t  right JOIN student s ON s.stuid = t.stuid
    and stuname like #{stuname}


  • 相关阅读:
    TP5.1 遇见问题整理
    PDO 基础
    php7 连接 mysql 的两种方式
    [php] 添加接口访问日志(文件)
    curl 向远程服务器传输file文件
    VBoxManage
    linux 系统下安装多个php版本
    vim中文乱码问题
    vim 翻页命令
    php list()函数
  • 原文地址:https://www.cnblogs.com/lemperor/p/14481423.html
Copyright © 2011-2022 走看看