当前位置: 首页>>代码示例>>Java>>正文


Java Page.getTotalPages方法代码示例

本文整理汇总了Java中org.springframework.data.domain.Page.getTotalPages方法的典型用法代码示例。如果您正苦于以下问题:Java Page.getTotalPages方法的具体用法?Java Page.getTotalPages怎么用?Java Page.getTotalPages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.data.domain.Page的用法示例。


在下文中一共展示了Page.getTotalPages方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generatePaginationHttpHeaders

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public static HttpHeaders generatePaginationHttpHeaders(Page page, String baseUrl) {

        HttpHeaders headers = new HttpHeaders();
        headers.add("X-Total-Count", Long.toString(page.getTotalElements()));
        String link = "";
        if ((page.getNumber() + 1) < page.getTotalPages()) {
            link = "<" + generateUri(baseUrl, page.getNumber() + 1, page.getSize()) + ">; rel=\"next\",";
        }
        // prev link
        if ((page.getNumber()) > 0) {
            link += "<" + generateUri(baseUrl, page.getNumber() - 1, page.getSize()) + ">; rel=\"prev\",";
        }
        // last and first link
        int lastPage = 0;
        if (page.getTotalPages() > 0) {
            lastPage = page.getTotalPages() - 1;
        }
        link += "<" + generateUri(baseUrl, lastPage, page.getSize()) + ">; rel=\"last\",";
        link += "<" + generateUri(baseUrl, 0, page.getSize()) + ">; rel=\"first\"";
        headers.add(HttpHeaders.LINK, link);
        return headers;
    }
 
开发者ID:deepu105,项目名称:spring-io,代码行数:23,代码来源:PaginationUtil.java

示例2: generatePaginationHttpHeaders

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public static HttpHeaders generatePaginationHttpHeaders(Page page, String baseUrl) {

        HttpHeaders headers = new HttpHeaders();
        headers.add("X-Total-Count", "" + Long.toString(page.getTotalElements()));
        String link = "";
        if ((page.getNumber() + 1) < page.getTotalPages()) {
            link = "<" + generateUri(baseUrl, page.getNumber() + 1, page.getSize()) + ">; rel=\"next\",";
        }
        // prev link
        if ((page.getNumber()) > 0) {
            link += "<" + generateUri(baseUrl, page.getNumber() - 1, page.getSize()) + ">; rel=\"prev\",";
        }
        // last and first link
        int lastPage = 0;
        if (page.getTotalPages() > 0) {
            lastPage = page.getTotalPages() - 1;
        }
        link += "<" + generateUri(baseUrl, lastPage, page.getSize()) + ">; rel=\"last\",";
        link += "<" + generateUri(baseUrl, 0, page.getSize()) + ">; rel=\"first\"";
        headers.add(HttpHeaders.LINK, link);
        return headers;
    }
 
开发者ID:SGKhmCs,项目名称:speakTogether,代码行数:23,代码来源:PaginationUtil.java

示例3: generatePaginationHttpHeaders

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public static HttpHeaders generatePaginationHttpHeaders(Page<?> page, String baseUrl)
    throws URISyntaxException {

    HttpHeaders headers = new HttpHeaders();
    headers.add("X-Total-Count", "" + page.getTotalElements());
    String link = "";
    if ((page.getNumber() + 1) < page.getTotalPages()) {
        link = "<" + (new URI(baseUrl +"?page=" + (page.getNumber() + 1) + "&size=" + page.getSize())).toString() + ">; rel=\"next\",";
    }
    // prev link
    if ((page.getNumber()) > 0) {
        link += "<" + (new URI(baseUrl +"?page=" + (page.getNumber() - 1) + "&size=" + page.getSize())).toString() + ">; rel=\"prev\",";
    }
    // last and first link
    link += "<" + (new URI(baseUrl +"?page=" + (page.getTotalPages() - 1) + "&size=" + page.getSize())).toString() + ">; rel=\"last\",";
    link += "<" + (new URI(baseUrl +"?page=" + 0 + "&size=" + page.getSize())).toString() + ">; rel=\"first\"";
    headers.add(HttpHeaders.LINK, link);
    return headers;
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:20,代码来源:PaginationUtil.java

示例4: list

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
@RequestMapping(path="/list")
	public String list(DictionarySearchCriteria criteria
			, Map<String, Object> model) {
		// setting default pageSize and sortFields
		if (criteria.isFirstInitialized()) {
			criteria.setPageSize(10);
			criteria.setSortFields("id:asc");
		}
//		logger.info("----------------------{}-------------------------", DictionaryType.PREDEFINED);
		Page<Dictionary> searchResult = this.dictionaryService.findAll(criteria.getPageable());
		Pagination pagination = new Pagination(criteria.getPageNo(), searchResult.getTotalPages(), searchResult.getTotalElements());
		model.put("searchResult", searchResult);
		model.put("criteria", criteria);
		model.put("pagination", pagination);
		return "tool/dictionary_list";
	}
 
开发者ID:Kevin-Huang-NZ,项目名称:springboot-jsp-generator,代码行数:17,代码来源:DictionaryController.java

示例5: home

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
@GetMapping("/home")
    public ModelAndView home(@RequestParam("pageSize") Optional<Integer> pageSize,
                             @RequestParam("page") Optional<Integer> page) {

        // Evaluate page size. If requested parameter is null, return initial
        // page size
        int evalPageSize = pageSize.orElse(INITIAL_PAGE_SIZE);
        // Evaluate page. If requested parameter is null or less than 0 (to
        // prevent exception), return initial size. Otherwise, return value of
        // param. decreased by 1.
        int evalPage = (page.orElse(0) < 1) ? INITIAL_PAGE : page.get() - 1;

//        Page<Post> posts = postService.findAllPageable(new PageRequest(evalPage, evalPageSize));
        Page<Post> posts = postService.findAllOrderedByDatePageable(new PageRequest(evalPage, evalPageSize));
        Pager pager = new Pager(posts.getTotalPages(), posts.getNumber(), BUTTONS_TO_SHOW);

        ModelAndView modelAndView = new ModelAndView();
//        Collection<Post> posts = postService.findNLatestPosts(5);
        modelAndView.addObject("posts", posts);
        modelAndView.addObject("selectedPageSize", evalPageSize);
        modelAndView.addObject("pageSizes", PAGE_SIZES);
        modelAndView.addObject("pager", pager);
        modelAndView.setViewName("home");
        return modelAndView;
    }
 
开发者ID:reljicd,项目名称:spring-boot-blog,代码行数:26,代码来源:HomeController.java

示例6: listUsersInternal

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
private String listUsersInternal(String search, int pageNumber, Model model) {
    if (search == null) {
        search = "";
    }

    // Page numbers in the URL start with 1
    PageRequest pageable = new PageRequest(pageNumber - 1, MAX_PAGE_SIZE);

    Page<UisUser> usersPage = uisUserService.findAllMatching(search, pageable);
    List<UisUser> users = usersPage.getContent();

    // If the user tries to access a page that doesn't exist
    if (users.size() == 0 && usersPage.getTotalElements() != 0) {
        int lastPage = usersPage.getTotalPages();
        return "redirect:/admin/users/page/" + lastPage + "?search=" + search;
    }

    model.addAttribute("page", usersPage);
    model.addAttribute("search", search);

    return "admin/users";
}
 
开发者ID:university-information-system,项目名称:uis,代码行数:23,代码来源:AdminUsersController.java

示例7: generatePaginationHttpHeaders

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public static HttpHeaders generatePaginationHttpHeaders(Page<?> page, String baseUrl)
    throws URISyntaxException {

    HttpHeaders headers = new HttpHeaders();
    headers.add("X-Total-Count", "" + page.getTotalElements());
    String link = "";
    if ((page.getNumber() + 1) < page.getTotalPages()) {
        link = "<" + generateUri(baseUrl, page.getNumber() + 1, page.getSize()) + ">; rel=\"next\",";
    }
    // prev link
    if ((page.getNumber()) > 0) {
        link += "<" + generateUri(baseUrl, page.getNumber() - 1, page.getSize()) + ">; rel=\"prev\",";
    }
    // last and first link
    int lastPage = 0;
    if (page.getTotalPages() > 0) {
        lastPage = page.getTotalPages() - 1;
    }
    link += "<" + generateUri(baseUrl, lastPage, page.getSize()) + ">; rel=\"last\",";
    link += "<" + generateUri(baseUrl, 0, page.getSize()) + ">; rel=\"first\"";
    headers.add(HttpHeaders.LINK, link);
    return headers;
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:24,代码来源:PaginationUtil.java

示例8: list

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
/**
 *文章列表
 * @param page
 * @param pageSize
 * @param model
 * @return
 */
@RequestMapping(value = "/list",method = RequestMethod.GET)
public String list(@RequestParam(value = "page", defaultValue = "0") Integer page, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, Model model) {
    if(page !=0) page = page -1;

    Page<ArticleDto> articleList = articleService.list(page);
    model.addAttribute("articleList",articleList);

    PageUtils pageUtils = new PageUtils("/admin/article/list?",page,articleList.getTotalPages(),articleList.getTotalElements(),pageSize);
    model.addAttribute("pb",pageUtils);

    return "admin/article/a_list";
}
 
开发者ID:realxujiang,项目名称:itweet-boot,代码行数:20,代码来源:ArticleController.java

示例9: generateSearchPaginationHttpHeaders

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public static HttpHeaders generateSearchPaginationHttpHeaders(String query, Page page, String baseUrl) {
    String escapedQuery;
    try {
        escapedQuery = URLEncoder.encode(query, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
    HttpHeaders headers = new HttpHeaders();
    headers.add("X-Total-Count", Long.toString(page.getTotalElements()));
    String link = "";
    if ((page.getNumber() + 1) < page.getTotalPages()) {
        link = "<" + generateUri(baseUrl, page.getNumber() + 1, page.getSize()) + "&query=" + escapedQuery + ">; rel=\"next\",";
    }
    // prev link
    if ((page.getNumber()) > 0) {
        link += "<" + generateUri(baseUrl, page.getNumber() - 1, page.getSize()) + "&query=" + escapedQuery + ">; rel=\"prev\",";
    }
    // last and first link
    int lastPage = 0;
    if (page.getTotalPages() > 0) {
        lastPage = page.getTotalPages() - 1;
    }
    link += "<" + generateUri(baseUrl, lastPage, page.getSize()) + "&query=" + escapedQuery + ">; rel=\"last\",";
    link += "<" + generateUri(baseUrl, 0, page.getSize()) + "&query=" + escapedQuery + ">; rel=\"first\"";
    headers.add(HttpHeaders.LINK, link);
    return headers;
}
 
开发者ID:pascalgrimaud,项目名称:qualitoast,代码行数:28,代码来源:PaginationUtil.java

示例10: list

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
/**
 * 资源列表
 * @param model
 * @return
 */
@LeftMenu(name = "资源列表",descritpion = "admin_permission_list",pname = "资源管理",url = "/admin/permission/list",operation = "list")
@RequestMapping(value = "/list",method = RequestMethod.GET)
public String list(@RequestParam(value = "page", defaultValue = "0") Integer page,Model model) {

    if(page !=0) page = page -1;

    Page<SysPermission> permissionList = permissionService.list(page);
    model.addAttribute("permissionList",permissionList);

    PageUtils pageUtils = new PageUtils("/admin/permission/list?",page,permissionList.getTotalPages(),permissionList.getTotalElements(),itweetProperties.getPagSize());
    model.addAttribute("pb",pageUtils);

    return "admin/user/p_list";
}
 
开发者ID:realxujiang,项目名称:itweet-boot,代码行数:20,代码来源:PermissionController.java

示例11: available

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
@Transactional // 必须包含该行,不只是懒加载问题,而是需要 transactional EntityManager available (无法得到FullTextEntityManager)
@Override
public Page<Article> search(String query, Pageable pageable) {
    Page<SearchResult<Article>> results = articleRepository.search(query, pageable);
    List<Article> articles = new ArrayList<>();
    results.getContent().forEach(item -> articles.add(item.getEntity()));
    return new PageImpl<>(articles, pageable, results.getTotalPages());
}
 
开发者ID:chaokunyang,项目名称:amanda,代码行数:9,代码来源:ArticleServiceImpl.java

示例12: index

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
/**
 * 热门标签,搜素标签
 */
@RequestMapping(value = "/tags", method = GET)
@Timed
public String index(Model model, @RequestParam(defaultValue = "1") int page, @RequestParam(required = false) String search) {
    long pages;
    page = page < 1 ? 1 : page - 1;

    Page<Tag> tags;

    if (search == null || search.trim().isEmpty()) {
        tags = tagService.getHotTags(page, PAGE_SIZE);
        long size = tagService.countTags();
        pages = size / PAGE_SIZE + (size % PAGE_SIZE != 0 ? 1 : 0);
    } else {
        // Do search tags
        tags = tagRepository.searchTags(
            search.toUpperCase(),
            new PageRequest(page, PAGE_SIZE, Sort.Direction.DESC, "postCount", "followersCount"));

        pages = tags.getTotalPages();
    }

    model.addAttribute("search", search == null ? "" : search.trim());
    model.addAttribute("tags", tags);
    model.addAttribute("page", page + 1);
    model.addAttribute("totalPages", pages);

    // Check whether the current user already followed the tags or not
    Map<Long, Boolean> followed = new HashMap<>();
    if (SecurityUtils.isAuthenticated()) {
        List<Long> tagIds = new ArrayList<>();
        tags.forEach(tag -> tagIds.add(tag.getId()));
        followed = tagService.isUserFollowedTags(tagIds, userService.getCurrentUserId());
    }
    model.addAttribute("followed", followed);

    return "tags/index";
}
 
开发者ID:ugouku,项目名称:shoucang,代码行数:41,代码来源:TagsController.java

示例13: tweet

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
@GetMapping(value = "/tweet")
public String tweet(@RequestParam(value = "page", defaultValue = "0") Integer page,Model model) {
    if(page != 0) page = page -1;

    model.addAttribute("tweet","selected");
    Page<ArticleDto> listArticle = articleService.list(page, ArticleUtils.getIsPublished(),ArticleUtils.getIsTweet());
    model.addAttribute("listArticle",listArticle);

    PageUtils pageUtils = new PageUtils("/tweet",page,listArticle.getTotalPages(),listArticle.getTotalElements(),itweetProperties.getPagSize());
    model.addAttribute("pb",pageUtils);

    return "front/theme/effe/tweet";
}
 
开发者ID:realxujiang,项目名称:itweet-boot,代码行数:14,代码来源:EffeController.java

示例14: list

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
@RequestMapping(value = "/list",method = RequestMethod.GET)
public String list(@RequestParam(value = "page", defaultValue = "0") Integer page,Model model) {
    if(page !=0) page = page -1;

    Page<Course> courseList = courseService.list(page);
    model.addAttribute("courseList",courseList);

    PageUtils pageUtils = new PageUtils("/admin/course/list?",page,courseList.getTotalPages(),courseList.getTotalElements(),itweetProperties.getPagSize());
    model.addAttribute("pb",pageUtils);

    return "admin/course/list";
}
 
开发者ID:realxujiang,项目名称:itweet-boot,代码行数:13,代码来源:CourseController.java


注:本文中的org.springframework.data.domain.Page.getTotalPages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。