我正在使用Spring Data REST测试Spring Boot,并且我遇到了分页功能的问题。这是代码:
@RepositoryRestResource(path="logEntry", exported=true)
public interface LogEntryRepository extends MongoRepository<LogEntry, String>{
@RestResource(path="/username", rel="/username")
Page<LogEntry> findByUsername(@Param("username") String username, Pageable pageable);
@RestResource(path="/sessionId", rel="/sessionId")
Page<LogEntry> findBySessionId(@Param("sessionId") String sessionId, Pageable pageable);
@RestResource(path="/source", rel="/source")
Page<LogEntry> findBySource(@Param("source") String source, Pageable pageable);
}
当我运行MongoRepository(/logEntry?size=100
)提供的端点时,分页工作正常。如果我尝试点击我的任何搜索端点并尝试调用分页(例如:/logEntry/search/source?source=1&size=100
),它会忽略分页并总是给我20分。
任何人都可以告诉我如何
答案 0 :(得分:1)
听起来你正在遇到this ticket的变体。它已在master和bugfix分支中得到解决,并计划在即将发布的版本中使用。不介意你试试快照(2.2.1.BUILD-SNAPSHOT和2.3.0.BUILD-SNAPSHOT)。如果你看到这个工作,完美。如果没有,请随意提出一个包含微小样本(最好是测试用例)的问题,以重现错误。
答案 1 :(得分:0)
要增加默认页面大小,您可以从<input type='text'>
<hr>
<table class="mytable">
<tbody>
<tr><td><input type='text'></td></tr>
<tr><td><input type='text'></td></tr>
<tr><td><input type='text'></td></tr>
</tbody>
</table>
指定spring.data.rest.default-page-size
属性,例如:
application.properties