小编Fla*_*oia的帖子

按数组列表自定义分页

我想在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返回

你能帮助我吗?

java spring pagination arraylist

6
推荐指数
1
解决办法
6196
查看次数

警告:管道标志“D”需要 dovecot_destination_recipient_limit = 1

我的后缀有问题。我正在通过 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)

postfix-mta dovecot

3
推荐指数
1
解决办法
3201
查看次数

MappingException:无效的路径引用club.name!关联只能直接指向或通过其id属性指向

我正在使用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)

java spring mongodb spring-data-mongodb

3
推荐指数
2
解决办法
2909
查看次数