zoukankan      html  css  js  c++  java
  • SpringMVC Servlet 分页查询接收参数

    @RequestMapping("/sendHistory")
    public ModelAndView sendrhistory(HttpServletRequest req, HttpServletResponse rep, @RequestParam int p) throws Exception {
    System.out.println("start...");
    String a=req.getParameter("status");
    ModelAndView modelAndView = new ModelAndView("send_history");
    Map<String, Object> map = dbUtilsTemplate.findFirst("select count(*) from message where user_id='" + getLoginUser().getId() + "'");
    Map<String, Object> map1 = dbUtilsTemplate.findFirst("select count(*) from message where user_id='" + getLoginUser().getId() + "' and status='DELIVERED'");

    int count = Integer.parseInt(map.get("count(*)").toString());
    int numbers=Integer.parseInt(map1.get("count(*)").toString());;
    String sql="";
    sql = "select country_code ,phone_number ,content ,b.dic_value status, send_time ,receive_time from message a," + "statusdic b where user_id='" + getLoginUser().getId() + "'" + " and a.api_name=b.api_name and a.status=b.dic_key order by send_time desc limit " + getPageStart(10, count, p) + ",10 ";
    //条件查询
    if(req.getParameter("status")!=null&&req.getParameter("status").equals("b"))
    {
    sql = "select country_code ,phone_number ,content ,b.dic_value status, send_time ,receive_time from message a,"
    + "statusdic b where user_id='" + getLoginUser().getId() + "'" +"and a.status='DELIVERED'"+
    " and a.api_name=b.api_name and a.status=b.dic_key and phone_number like '%" + req.getParameter("phone_number")
    + "%' order by send_time desc limit " + getPageStart(10, count, p) + ",10 " ;
    System.out.println(sql);
    }
    if(req.getParameter("status")!=null&&req.getParameter("status").equals("c")){
    sql = "select country_code ,phone_number ,content ,b.dic_value status, send_time ,receive_time from message a,"
    + "statusdic b where user_id='" + getLoginUser().getId() + "'" +"and status='0'"+
    " and a.api_name=b.api_name and a.status=b.dic_key and phone_number like '%" + req.getParameter("phone_number")
    + "%' order by send_time desc limit " + getPageStart(10, count, p) + ",10 " ;
    }
    if(req.getParameter("status")!=null&&req.getParameter("status").equals("a")){
    sql = "select country_code ,phone_number ,content ,b.dic_value status, send_time ,receive_time from message a,"
    + "statusdic b where user_id='" + getLoginUser().getId() + "'" +
    " and a.api_name=b.api_name and a.status=b.dic_key and phone_number like '%" + req.getParameter("phone_number")
    + "%' order by send_time desc limit " + getPageStart(10, count, p) + ",10 " ;
    }
    System.out.println(sql);
    List<Message> list = dbUtilsTemplate.find(Message.class, sql);

    modelAndView.addObject("numbers", numbers);
    modelAndView.addObject("list", list);
    modelAndView.addObject("status", a);
    modelAndView.addObject("phone", req.getParameter("phone_number"));
    return modelAndView;

    }

  • 相关阅读:
    Stanford coursera Andrew Ng 机器学习课程编程作业(Exercise 2)及总结
    zookeeper Eclipse 开发环境搭建及简单示例
    PHP语言基础之MySql 05 By ACReaper
    【读书笔记】并发编程需要注意的几个典型问题
    Eclipse安装SVN
    html学习
    某浪PHP面试题及答案优化
    《卡特教练》观后感
    [Usaco2006 Nov]Roadblocks第二短路
    std::vector 两种操作的比较
  • 原文地址:https://www.cnblogs.com/jessi/p/4758381.html
Copyright © 2011-2022 走看看