购物商城---开发流程--获取品牌列表
2017-04-18 15:45
134 查看
controller
Pagination pagination = brandService.getBrandListWithPage(brand);
brandDao.getBrandListWithPage(brand)
调用mybatis
最后将数据返回
// 品牌列表页面 @RequestMapping(value = "/brand/list.do") // pageNo 传入的页面号码 public String list(String name, Integer isDisplay, Integer pageNo, ModelMap model) { Brand brand = new Brand(); // sb 拼接页面请求参数 StringBuilder sb = new StringBuilder(); // 空串notblank "" null if (StringUtils.isNotBlank(name)) { brand.setName(name); sb.append("name=").append(name); } if (isDisplay != null) { brand.setIsDisplay(isDisplay); sb.append("&").append("isDisplay=").append(isDisplay); }else{ brand.setIsDisplay(1); sb.append("&").append("isDisplay=1"); } // 页号 如果pageNo<1 或为null 设置pageNo=1 brand.setPageNo(Pagination.cpn(pageNo)); // 每页数 brand.setPageSize(5); // 分页对象,调用service层获取数据 Pagination pagination = brandService.getBrandListWithPage(brand); // 页面展示 String url = "/brand/list.do"; pagination.pageView(url, sb.toString()); // 返回给页面 model.addAttribute("pagination", pagination);// 底层request.setAttribute实现 model.addAttribute("isDisplay", brand.getIsDisplay());// 底层request.setAttribute实现 model.addAttribute("name", name);// 底层request.setAttribute实现 return "brand/list"; }
Pagination pagination = brandService.getBrandListWithPage(brand);
public Pagination getBrandListWithPage(Brand brand) { // 1:页号 // 2:每页数 // 3:总记录数 Pagination Pagination = new Pagination(brand.getPageNo(), brand.getPageSize(), brandDao.getBrandCount(brand)); // 品牌数据集合//调用dao层获取数据 Pagination.setList(brandDao.getBrandListWithPage(brand)); return Pagination; }
brandDao.getBrandListWithPage(brand)
// list集合 public List<Brand> getBrandListWithPage(Brand brand);
调用mybatis
<!--#{isDisplay}获取对象字段值 --> <!-- 查询品牌 get* --> <select id="getBrandListWithPage" parameterType="Brand" resultMap="brand"> select id,name,description,img_url,web_site,sort,is_display from bbs_brand <where> <if test="isDisplay != null"> is_display=#{isDisplay} </if> <if test="name != null"> and name=#{name} </if> </where> order by id desc limit #{startRow},#{pageSize} </select>
最后将数据返回
相关文章推荐
- 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取"产品付费数量等于0的问题"】
- 微信小程序购物商城系统开发系列-目录结构
- 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取"产品付费数量等于0的问题"】
- 微信小程序购物商城系统开发系列-目录结构
- CSR8670获取来电号码及开发流程
- 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取"产品付费数量等于0的问题"】
- 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取"产品付费数量等于0的问题"】
- 微信小程序购物商城系统开发系列-目录结构
- 微信小程序购物商城定制开发
- 安卓从零开发之购物商城(一)--底部菜单栏的的实现(FragmentTabHost)
- 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取"产品付费数量等于0的问题"】
- JavaWeb开发使用Cookie创建-获取-持久化、自动登录、购物记录、作用路径
- 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取"产品付费数量等于0的问题"】
- 微信小程序购物商城系统开发系列-工具篇
- 微信小程序购物商城系统开发系列-目录结构
- 工业相机软件开发 影像数据获取流程
- 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取"产品付费数量等于0的问题"】
- 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取"产品付费数量等于0的问题"】
- iWebShop 二次开发之商城后台模板渲染流程
- 商城购物,最近浏览过的商品的开发