1,controller层
package com.example.demo3.controller;
import com.example.demo3.entity.Hot_move;
import com.example.demo3.mapper.PageMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController
public class Page {
@Resource
PageMapper pageMapper;
@RequestMapping(path = "/page",method = RequestMethod.GET)
public List<Hot_move> getPage(int page, int size){
return pageMapper.getPage(page,size);
}
}
2,mapper层
package com.example.demo3.mapper;
import com.example.demo3.entity.Hot_move;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface PageMapper {
//limit分页select * from table_name limit 10,5
@Select("select * from hot_move limit ${(page-1)*size},${size};")
List<Hot_move> getPage(int page, int size);
}