国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

ajax動態(tài)查詢數(shù)據(jù)庫數(shù)據(jù)并顯示在前臺的方法

瀏覽:66日期:2022-06-11 13:09:26

今天做了一個ajax動態(tài)查詢數(shù)據(jù)庫的小Demo,又重新學習了一下ajax的一些知識。在此和大家分享一下......

啥都別說了,先上代碼

Controller層

查詢總用戶數(shù)

 @RequestMapping(value = "/findTotalUsers.do",method = RequestMethod.GET) public @ResponseBody Long findTotalUsers(){  ModelAndView modelAndView = new ModelAndView();  Long sum = personService.findTotalUsers();  System.out.println(sum+"....................................");  modelAndView.addObject("sum",sum);  return sum; }

Service層

public Long findTotalUsers() {  return personDao.findTotalUsers(); }

Dao層

public Long findTotalUsers() {  String hql = "select count(*) from Person";  return (Long) this.getSessionFactory().getCurrentSession().createQuery(hql).uniqueResult(); }

ajax代碼

<script src="../js/jquery-1.8.3.min.js" type="text/javascript"></script> <script type="text/javascript">  $(document).ready(    function ajaxRePost(url,params){     var message = "";     var options={      type:"GET",      url:"${pageContext.request.contextPath}/person/findTotalUsers.do",      data:{},      async:false,      success:function (msg) {       message=msg;      }     };     $.ajax(options);     alert(message);//     debugger;     $("#count").text(message);     return message;    }  )  </script>

結(jié)果就是在Total Users 動態(tài)查詢數(shù)據(jù)庫中的數(shù)據(jù)并更新........

以上這篇ajax動態(tài)查詢數(shù)據(jù)庫數(shù)據(jù)并顯示在前臺的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持。

標簽: Ajax
相關(guān)文章:
主站蜘蛛池模板: 丰城市| 莱阳市| 临沧市| 肇东市| 胶南市| 富宁县| 南康市| 邵阳县| 大宁县| 涿鹿县| 农安县| 尤溪县| 广饶县| 台湾省| 汉阴县| 花垣县| 繁昌县| 东丽区| 凤凰县| 海口市| 峨山| 房产| 无为县| 平舆县| 柳江县| 盐源县| 阳原县| 通化县| 昌黎县| 武强县| 丁青县| 酒泉市| 象州县| 汕尾市| 周宁县| 永靖县| 开远市| 开原市| 新和县| 凤阳县| 中江县|