@ GetMapping
Public Object GetVacations (
@ PageableDefault (page=2, size=4, sort={} "id, desc") Pageable Pageable) {
List
For vacations.=vacationMapper getVacations (pageable);
Return for vacations.
}
Mapper code is such,
@ the Select (" Select * FROM VACATION WHERE state='has been off the order by ${sort} limit ${page}, ${size} ")
List
Modified to:
@ the Select (" Select * FROM VACATION WHERE state='has been off the order by id limit ${page}, ${size} ")
List
Can run, I function is achieved, is now want to know the sort used here, see PageableDefault annotations to the source code, this sort is a String [], an array type,
There are two problems:
1 is in mybatis query processing of the parameters of the array?
2 this case whether there is any other way, on the Internet to see some people in the select statement does not apply the three parameters, I also tried, such pageable doesn't work, don't know how to get paging information, they are going to do?
CodePudding user response:
Mybatis paging suggest using PageHelperCodePudding user response:
Not limit ${page}, ${size}"But limit ${offset}, ${size}
")
Page not found a good plug-in, felling oneself write more appropriate
I had originally thought that the spring pageable, can be independent of the mapper. XML
As long as the mapper configuration query
Can automatically calculate the total