> //20201127
> 写在前面:今天在做个人博客的时候,需要对标签排个序,就想着创建一个sort对象(其实sort也不支持,解决方法见此博客:Spring(2.1.1)下Srot类不再支持直接实例化对象)然后配合PageRequest对象使用,但是发现创建PageRequest对象语句爆红,点进源码一看,发现其构造已经被私有化,所以改变方案使用其内部方法来返回对象
- 语句爆红如图
- 使用静态of方法获取对象具体如图
- PageRequest下静态of方法源码如图
> ps:内部有重载of方法,可传不同参数,具体不在此一一列出
##### 以上
##### 希望对大家有所帮助