我想在java代码中创建一个数组列表的自定义分页
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Sort.Direction;
...
int page = 0;
int count = 8;
String sortOrder = "desc";
String sortBy = "id";
Sort sort = new Sort(Direction.fromString(sortOrder), sortBy);
PageRequest pageable = new PageRequest(page, count, sort);
List<Impianto> impiantos = myService.findMyMethod(); // returned 30 objects
Page<Impianto> pageImpianto = new PageImpl<Impianto>(impiantos, pageable, impiantos.size());
Run Code Online (Sandbox Code Playgroud)
上面的脚本不会返回包含8个元素的页面.为什么?
NB列表没有从db返回
你能帮助我吗?
我的后缀有问题。我正在通过 postfix + dovecot + spamassassin 和 clamav 设置我的服务器邮件。当我发送多封电子邮件时,日志中会出现以下警告。
Dec 14 12:37:52 mydomain postfix/pipe[30312]: 72210100722: to=<john.doe@mydomain.com>, relay=dovecot, delay=0.35, delays=0.23/0/0/0.11, dsn=4.3.5, status=deferred (mail system configuration error)
Dec 14 12:37:52 mydomain postfix/pipe[30312]: warning: pipe flag `D' requires dovecot_destination_recipient_limit = 1
Run Code Online (Sandbox Code Playgroud) 我正在使用Spring Data Mongodb库,我不知道通过@Query在与@DBRef连接的两个集合中查找元素,如下所示:
用户:
@Document
public class User {
@Id
@JsonSerialize(using=ObjectIdSerializer.class)
private ObjectId id;
@CreatedDate
private Date dateCreated = new Date();
@LastModifiedDate
private Date dateModified = new Date();
@NotEmpty
@Indexed
private String name;
@Language
private String lang;
@NotEmpty
@DBRef
private Club club;
...
Run Code Online (Sandbox Code Playgroud)
俱乐部:
@Document
public class Club {
@Id
@JsonSerialize(using=ObjectIdSerializer.class)
private ObjectId id;
@Indexed(unique = true)
private String name;
private Address address;
...
Run Code Online (Sandbox Code Playgroud)
UserRepository:
@Query("{\"$or\":"
+ "["
+ "{\"name\" : {\"$regex\" : ?0, \"$options\": \"i\"}}, "
+ "{\"club.name\" : …Run Code Online (Sandbox Code Playgroud)