分页上传多条件查询
Posted qsy0021
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了分页上传多条件查询相关的知识,希望对你有一定的参考价值。
//测试foreach标签 @RequestMapping("/goList") public void testList(int test1 , int test2 , int test3) throws SQLException { //将获取到的OID的值存储到集合中 List<Integer> list = new ArrayList<Integer>() ; list.add(test1) ; list.add(test2) ; list.add(test3) ; List<FDetail> details = userService.testList(list) ; for(FDetail f :details) { System.out.println(f.getAccount() + " " + f.getPrice()); } } // 完成上传功能 @RequestMapping(value = "/upload", method = RequestMethod.POST) public String upload(@RequestParam("p") MultipartFile file , Flower flower) throws IllegalStateException, IOException, SQLException { // 获取到上传的内容的名字 String pic = file.getOriginalFilename(); System.out.println(pic); String p = new String(pic.getBytes("iso-8859-1"), "utf-8"); System.out.println(p); File f = new File("D:/img/" + pic); // 将上传的内容的信息存储到服务器中 file.transferTo(f); System.out.println("trans"); // 通过以上参数可以获取到flower对象的除图片之外的值 flower.setPic(p); userService.uploadF(flower); return "back/back.jsp"; } // 完成分页功能 @RequestMapping("/morepage") public String morepage(HttpServletRequest req) { // 获取当前页 String page = req.getParameter("page"); page = (page == null ? "1" : page);// 获取当前页如果第一次进入,则获取的page值为空,所以需要给它赋值为1,否则它的值为获取的page的值 int p = Integer.parseInt(page); req.setAttribute("up", p - 1);// 上一页 req.setAttribute("down", p + 1);// 下一页 req.setAttribute("page", p); String name = req.getParameter("flowername"); String start = req.getParameter("start"); String end = req.getParameter("end"); // 所以需要将name,star,end的值进行存储,以便点击分页之后页面依然可以获取到之前添加的条件 req.setAttribute("name", name); req.setAttribute("start", start); req.setAttribute("end", end); String re = ""; // req.setAttribute("name" , name) ; // req.setAttribute("start", start); // req.setAttribute("end", end); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); Date s = null, en = null; try { if (start != null && !start.equals("")) s = sdf.parse(start); if (end != null && !end.equals("")) en = sdf.parse(end); } catch (ParseException e) { //Log.logger.debug(e.getMessage()); e.printStackTrace(); } // 需要获取到一共有多少页 int all = 0; try { all = userService.getPage(name, s, en, 2, p);//此总页码为多条件查询结果的总页码 //all = service.getPageOne(name , s , en , 2 , p) ;//此总页码为查询某个条件的总页码 } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } req.setAttribute("all", all); try { List<Forder> list = userService.queryOrder(name, s, en, 2, p);//完成页面的多条件查询 //List<Forder> list = service.queryOne(name, s, en,2, p) ;//完成页面的某个条件查询 req.setAttribute("list", list); // req.getRequestDispatcher("back/back.jsp").forward(req, resp); re = "back/back.jsp"; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return re; } // 完成多条件查询功能 @RequestMapping(value = "/more", method = RequestMethod.POST) public String more(HttpServletRequest req) { // 获取当前页 String page = req.getParameter("page"); page = (page == null ? "1" : page);// 获取当前页如果第一次进入,则获取的page值为空,所以需要给它赋值为1,否则它的值为获取的page的值 int p = Integer.parseInt(page); req.setAttribute("up", p - 1);// 上一页 req.setAttribute("down", p + 1);// 下一页 req.setAttribute("page", p); String name = req.getParameter("flowername"); String start = req.getParameter("start"); String end = req.getParameter("end"); // 所以需要将name,star,end的值进行存储,以便点击分页之后页面依然可以获取到之前添加的条件 req.setAttribute("name", name); req.setAttribute("start", start); req.setAttribute("end", end); String re = ""; // req.setAttribute("name" , name) ; // req.setAttribute("start", start); // req.setAttribute("end", end); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); Date s = null, en = null; try { if (start != null && !start.equals("")) s = sdf.parse(start); if (end != null && !end.equals("")) en = sdf.parse(end); } catch (ParseException e) { // Log.logger.debug(e.getMessage()); e.printStackTrace(); } // 需要获取到一共有多少页 int all = 0; try { all = userService.getPage(name, s, en, 2, p); //all = service.getPageOne(name, s, en, 2, p) ; } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } req.setAttribute("all", all); try { List<Forder> list = userService.queryOrder(name, s, en, 2, p); //List<Forder> list = service.queryOne(name, s, en, 2, p) ; req.setAttribute("list", list); // req.getRequestDispatcher("back/back.jsp").forward(req, resp); re = "back/back.jsp"; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return re; } // 完成后台页面跳转功能 @RequestMapping("/back") public String back() { return "back/back.jsp"; }
以上是关于分页上传多条件查询的主要内容,如果未能解决你的问题,请参考以下文章
Django-rest-framework多条件查询/分页/多表Json