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


Java Page.getNumber方法代码示例

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


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

示例1: generateSearchPaginationHttpHeaders

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public static HttpHeaders generateSearchPaginationHttpHeaders(String query, 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()) + "&query=" + query + ">; rel=\"next\",";
    }
    // prev link
    if ((page.getNumber()) > 0) {
        link += "<" + generateUri(baseUrl, page.getNumber() - 1, page.getSize()) + "&query=" + query + ">; rel=\"prev\",";
    }
    // last and first link
    int lastPage = 0;
    if (page.getTotalPages() > 0) {
        lastPage = page.getTotalPages() - 1;
    }
    link += "<" + generateUri(baseUrl, lastPage, page.getSize()) + "&query=" + query + ">; rel=\"last\",";
    link += "<" + generateUri(baseUrl, 0, page.getSize()) + "&query=" + query + ">; rel=\"first\"";
    headers.add(HttpHeaders.LINK, link);
    return headers;
}
 
开发者ID:AppertaFoundation,项目名称:Code4Health-Platform,代码行数:24,代码来源:PaginationUtil.java

示例2: 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:ugouku,项目名称:shoucang,代码行数:20,代码来源:PaginationUtil.java

示例3: generateSearchPaginationHttpHeaders

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public static HttpHeaders generateSearchPaginationHttpHeaders(String query, Page page, String baseUrl) {
    String escapedQuery = query.replace(",", "%2C");
    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:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:23,代码来源:PaginationUtil.java

示例4: 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

示例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: 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<Product> products = productService.findAllProductsPageable(new PageRequest(evalPage, evalPageSize));
        Pager pager = new Pager(products.getTotalPages(), products.getNumber(), BUTTONS_TO_SHOW);

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

示例7: 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:ElectronicArmory,项目名称:Armory,代码行数:23,代码来源:PaginationUtil.java

示例8: generateSearchPaginationHttpHeaders

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

        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()) + "&query=" + query + ">; rel=\"next\",";
        }
        // prev link
        if ((page.getNumber()) > 0) {
            link += "<" + generateUri(baseUrl, page.getNumber() - 1, page.getSize()) + "&query=" + query + ">; rel=\"prev\",";
        }
        // last and first link
        int lastPage = 0;
        if (page.getTotalPages() > 0) {
            lastPage = page.getTotalPages() - 1;
        }
        link += "<" + generateUri(baseUrl, lastPage, page.getSize()) + "&query=" + query + ">; rel=\"last\",";
        link += "<" + generateUri(baseUrl, 0, page.getSize()) + "&query=" + query + ">; rel=\"first\"";
        headers.add(HttpHeaders.LINK, link);
        return headers;
    }
 
开发者ID:IBM,项目名称:Microservices-with-JHipster-and-Spring-Boot,代码行数:23,代码来源:PaginationUtil.java

示例9: 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

示例10: 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", "" + 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:AppertaFoundation,项目名称:Code4Health-Platform,代码行数:24,代码来源:PaginationUtil.java

示例11: homepage

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
@GetMapping("/")
public ModelAndView homepage(@RequestParam("pageSize") Optional<Integer> pageSize,
		@RequestParam("page") Optional<Integer> page){
	
	if(clientrepository.count()!=0){
		;//pass
	}else{
		addtorepository();
	}
	
	ModelAndView modelAndView = new ModelAndView("index");
	//
	// 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;
	// print repo
	System.out.println("here is client repo " + clientrepository.findAll());
	Page<ClientModel> clientlist = clientrepository.findAll(new PageRequest(evalPage, evalPageSize));
	System.out.println("client list get total pages" + clientlist.getTotalPages() + "client list get number " + clientlist.getNumber());
	PagerModel pager = new PagerModel(clientlist.getTotalPages(),clientlist.getNumber(),BUTTONS_TO_SHOW);
	// add clientmodel
	modelAndView.addObject("clientlist",clientlist);
	// evaluate page size
	modelAndView.addObject("selectedPageSize", evalPageSize);
	// add page sizes
	modelAndView.addObject("pageSizes", PAGE_SIZES);
	// add pager
	modelAndView.addObject("pager", pager);
	return modelAndView;
	
}
 
开发者ID:michaelcgood,项目名称:PagingAndSortingRepository-Example,代码行数:36,代码来源:ClientController.java

示例12: mapPage

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public static <S, T> Page<T> mapPage(Page<S> source, Class<T> targetClass) {
    List<S> sourceList = source.getContent();

    List<T> list = new ArrayList<>();
    for (int i = 0; i < sourceList.size(); i++) {
        T target = INSTANCE.map(sourceList.get(i), targetClass);
        list.add(target);
    }

    return new PageImpl<>(list, new PageRequest(source.getNumber(), source.getSize(), source.getSort()),
        source.getTotalElements());
}
 
开发者ID:lordking,项目名称:spring-rest-sample,代码行数:13,代码来源:DTOUtils.java

示例13: 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

示例14: generateSearchPaginationHttpHeaders

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

    HttpHeaders headers = new HttpHeaders();
    headers.add("X-Total-Count", "" + page.getTotalElements());
    String link = "";
    String queryUrl = URLEncoder.encode(query, "UTF-8");

    if ((page.getNumber() + 1) < page.getTotalPages()) {
        link = "<" + generateUri(baseUrl, page.getNumber() + 1, page.getSize()) + "&query=" + queryUrl + ">; rel=\"next\",";
    }
    // prev link
    if ((page.getNumber()) > 0) {
        link += "<" + generateUri(baseUrl, page.getNumber() - 1, page.getSize()) + "&query=" + queryUrl + ">; rel=\"prev\",";
    }
    // last and first link
    int lastPage = 0;
    if (page.getTotalPages() > 0) {
        lastPage = page.getTotalPages() - 1;
    }


    link += "<" + generateUri(baseUrl, lastPage, page.getSize()) + "&query=" + queryUrl + ">; rel=\"last\",";
    link += "<" + generateUri(baseUrl, 0, page.getSize()) + "&query=" + queryUrl + ">; rel=\"first\"";
    headers.add(HttpHeaders.LINK, link);
    return headers;
}
 
开发者ID:klask-io,项目名称:klask-io,代码行数:28,代码来源:PaginationUtil.java

示例15: getAllEmailsPaged

import org.springframework.data.domain.Page; //导入方法依赖的package包/类
private String getAllEmailsPaged(int page, int size, Model model) {
    if(page < 0 || size <= 0){
        return REDIRECT_EMAIL_LIST_VIEW;
    }
    Page<Email> result = emailRepository.findAll(new PageRequest(page, size, DEFAULT_SORT));
    if (result.getNumber() != 0 && result.getNumber() >= result.getTotalPages()) {
        return REDIRECT_EMAIL_LIST_VIEW;
    }
    model.addAttribute(EMAIL_LIST_MODEL_NAME, result);
    return EMAIL_LIST_VIEW;
}
 
开发者ID:gessnerfl,项目名称:fake-smtp-server,代码行数:12,代码来源:EmailController.java


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