使用 PagingAndSortingRepository 内容返回 {} 和来自页面 url 参数的正确内容数。示例:我的表有 20 行,在 url 中有一个 put ?page=0&size=10。邮递员返回时关键内容返回
"content": [
{},
{},
{},
{},
{},
{},
{},
{},
{},
{}
]
调试请求并返回它有值。但是不显示。不知道为什么。
我的仓库
public interface LocalUtilRepository extends PagingAndSortingRepository<LocalUtilModel, Integer> {
Page<LocalUtilModel> findAll(Pageable pageable);
}
春季启动版本
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
请求的结果
{
"content": [
{},
{},
{},
{},
{},
{},
{},
{},
{},
{}
],
"pageable": {
"sort": {
"sorted": false,
"unsorted": true,
"empty": true
},
"offset": 0,
"pageNumber": 0,
"pageSize": 10,
"unpaged": false,
"paged": true
},
"totalPages": 2,
"totalElements": 11,
"last": false,
"size": 10,
"number": 0,
"sort": {
"sorted": false,
"unsorted": true,
"empty": true
},
"numberOfElements": 10,
"first": true,
"empty": false
}
我的模型
@Entity(name = "EXPLOCALUTIL")
public class LocalUtilModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@NotNull
@Size(min = 5, max = 255)
@Column(name = "DESCLOCALUTIL")
private String descLocalUtil;
@Column(name = "COORD")
private String coordenada;
private String referencia;
@NotNull
@Column(name = "IDEXPFEIRA")
private Integer idExpFeira;
}
繁花如伊
侃侃尔雅
相关分类