Java tutorial
/* * Copyright 2005-2013 shopxx.net. All rights reserved. * Support: http://www.shopxx.net * License: http://www.shopxx.net/license */ package net.groupbuy.controller.shop; import javax.annotation.Resource; import net.groupbuy.Pageable; import net.groupbuy.ResourceNotFoundException; import net.groupbuy.entity.Brand; import net.groupbuy.service.BrandService; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; /** * Controller - ? * * @author SHOP++ Team * @version 3.0 */ @Controller("shopBrandController") @RequestMapping("/brand") public class BrandController extends BaseController { /** ? */ private static final int PAGE_SIZE = 40; @Resource(name = "brandServiceImpl") private BrandService brandService; /** * */ @RequestMapping(value = "/list/{pageNumber}", method = RequestMethod.GET) public String list(@PathVariable Integer pageNumber, ModelMap model) { Pageable pageable = new Pageable(pageNumber, PAGE_SIZE); model.addAttribute("page", brandService.findPage(pageable)); return "/shop/brand/list"; } /** * */ @RequestMapping(value = "/content/{id}", method = RequestMethod.GET) public String content(@PathVariable Long id, ModelMap model) { Brand brand = brandService.find(id); if (brand == null) { throw new ResourceNotFoundException(); } model.addAttribute("brand", brand); return "/shop/brand/content"; } }