码迷,mamicode.com
首页 > Web开发 > 详细

jQuery-按回车发送事件

时间:2020-06-05 21:12:25      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:==   app   string   模糊   new   服务   模糊查询   map   arch   

##发送ajax请求

发送事件:输入关键词后,点回车

请求的参数:输入的关键字

请求地址:/share/search.do

##服务器处理

-Controller:调用Service层方法即可

-Service:

public ResultNote<List<Share>> searchNote(String keyWord){

  //拼接模糊查询

  String title = "%"+keyWord+"%";

   //模糊查询

  List<Share> list = shareDao.findLikeTitle(title);

  //构建返回结果

  ResultNote<List<Share>> result = new ResultNote<List<Share>>();

  ......

  result.setDate(list);

  return result;

}

-Dao(select):findLikeTitle

cn_share:select * from cn_share where xxx like %关键词%

 

Mapper中配置的sql语句:

select * from cn_share where cn_share_title like #{title}

 

##ajax回调处理

$("#input_id").keydown(function(event){

  var code = event.keyCode;

  if(code==13){

    //发送ajax请求

  }

})

jQuery-按回车发送事件

标签:==   app   string   模糊   new   服务   模糊查询   map   arch   

原文地址:https://www.cnblogs.com/gol2q/p/13052179.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!