在Spring Boot上设置Pageable限制

时间:2017-03-04 13:21:49

标签: spring spring-mvc spring-boot spring-restcontroller

我有一个

@ResponseBody
@Produces("application/json")
@RequestMapping(value = "/users", method = RequestMethod.GET)
public Page<User> getRecentUsers(Pageable pageable,
                                    HttpServletResponse response){
    return userRepository.findAll(pageable);
}

我是否可以自动为可分页的pageSize设置限制,而无需单独接受page和pageSize?

1 个答案:

答案 0 :(得分:0)

您可以在将可分页对象传递给findAll之前对其进行修改。

无论如何,作为一个界面,你必须用它来构建一个新对象。类似的东西:

 function attach_coupons_pdf_to_email($attachments, $status, $order)
{
    the_log("\n " . $status .  " \n");
    if (isset($status) && strcmp($status, "wc_welcome") == 0)
    {
        array_push($attachments, trailingslashit(ABSPATH) . "coupons/gutschein-1488685005124.pdf");
        array_push($attachments, trailingslashit(ABSPATH) . "coupons/gutschein-1488704520421.pdf");
        array_push($attachments, trailingslashit(ABSPATH) . "coupons/gutschein-1488704521893.pdf");
      //  array_push($attachments, trailingslashit(ABSPATH) . "coupons/gutschein-1488704520454.pdf"); Doesn't send anymore
    }
    return $attachments;
}

add_filter('woocommerce_email_attachments', 'attach_coupons_pdf_to_email', 2, 3);