/** * Обработка AJAX-запроса * * @param id - id товара, для которого нужно подгружать комментарии */ @RequestMapping(value = "/showMore", method = RequestMethod.POST) public String renderComments(Long id, Model model) { List<ReviewInfo> allComments = reviewService.getByGoodId(id); List<ReviewInfo> newComments = new ArrayList<ReviewInfo>(); if (allComments.size() > 0) { newComments = allComments.subList(from, allComments.size()); } model.addAttribute("comments", newComments); return "good/ajaxComments"; }
/** * Отображение карточки товара * * @param goodId id товара */ @IncludeMenuInfo @RequestMapping(value = "/{id}", method = RequestMethod.GET) public String renderGoodPage(@PathVariable("id") Long goodId) { GoodInfo good = goodService.getById(goodId); if (good != null) { request.setAttribute("good", good); request.setAttribute("populars", goodService.getTop5ByCategory(good.getCategory().getId())); List<ReviewInfo> comments = reviewService.getByGoodId(goodId); request.setAttribute("AllComments", comments); if (comments.size() > 3) { request.setAttribute("comments", comments.subList(0, from)); } else { request.setAttribute("comments", comments); } } return "good/goodPage"; }