mschipperheyn
Jun 8th, 2008, 04:22 AM
Hi,
Just wondering what the best approach was to pagination using annotations. I figured Spring would recognize different method signatures with an identical path as different but this leads to a 404.
@Controller
@RequestMapping("/account/offers/listoffers.html")
public class VendorOfferListController {
OfferManager offerMgr;
@Autowired
public void setOfferManager(OfferManager offerMgr) {
this.offerMgr = offerMgr;
}
@RequestMapping(method = RequestMethod.GET)
public String handleOffers(
ModelMap model,
HttpServletRequest request,
HttpServletResponse response) {
return handleOffersBase(0, 10, model, request, response);
}
@RequestMapping(method = RequestMethod.GET)
public String handleOffersFromTo(
@RequestParam("max")
int max,
@RequestParam("start")
int start,
ModelMap model,
HttpServletRequest request,
HttpServletResponse response) {
return handleOffersBase(start, max, model, request, response);
}
public String handleOffersBase(
int start,
int max,
ModelMap model,
HttpServletRequest request,
HttpServletResponse response) {
User user = (User) request.getSession()
.getAttribute(Project.USER_KEY);
List<Offer> offers = offerMgr.getOffers(user, start, max);
model.addAttribute("listOffers", offers);
return "offerlist";
}
Just wondering what the most elegant way would be to handle it.
Cheers,
Marc
Just wondering what the best approach was to pagination using annotations. I figured Spring would recognize different method signatures with an identical path as different but this leads to a 404.
@Controller
@RequestMapping("/account/offers/listoffers.html")
public class VendorOfferListController {
OfferManager offerMgr;
@Autowired
public void setOfferManager(OfferManager offerMgr) {
this.offerMgr = offerMgr;
}
@RequestMapping(method = RequestMethod.GET)
public String handleOffers(
ModelMap model,
HttpServletRequest request,
HttpServletResponse response) {
return handleOffersBase(0, 10, model, request, response);
}
@RequestMapping(method = RequestMethod.GET)
public String handleOffersFromTo(
@RequestParam("max")
int max,
@RequestParam("start")
int start,
ModelMap model,
HttpServletRequest request,
HttpServletResponse response) {
return handleOffersBase(start, max, model, request, response);
}
public String handleOffersBase(
int start,
int max,
ModelMap model,
HttpServletRequest request,
HttpServletResponse response) {
User user = (User) request.getSession()
.getAttribute(Project.USER_KEY);
List<Offer> offers = offerMgr.getOffers(user, start, max);
model.addAttribute("listOffers", offers);
return "offerlist";
}
Just wondering what the most elegant way would be to handle it.
Cheers,
Marc