码迷,mamicode.com
首页 > 编程语言 > 详细

SpringMVC Servlet 分页查询接收参数

时间:2015-08-25 21:23:27      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

@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;

}

SpringMVC Servlet 分页查询接收参数

标签:

原文地址:http://www.cnblogs.com/jessi/p/4758381.html

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