通过easycode插件生成代码后运行遇到的问题

1、controller层的分页查询方法中参数pageRequest接收不到前台,传递的int page和int size参数,并提示没有相应的构造

public ResponseEntity<Page<User>> queryByPage(User user,PageRequest pageRequest)

原因:PageRequest 所在包升级废弃了该类的构造

解决方案:如下

public ResponseEntity<Page<User>> queryByPage(User user, @RequestParam("page") int pageIndex,@RequestParam("size") int pageSize)

2、controller层的分页查询方法,在dao层访问数据库时,提示未找到对应的#{id},而id实际上为user对象的属性,由于有入参有两个对象

List<User> queryAllByLimit(User user, @Param("pageable") Pageable pageable);

问题的原因:由于有入参有两个对象,需要指定两个对象的名称,且在xml文件中需要通过#{user.id}的方式获取属性

List<User> queryAllByLimit(@Param("user")User user, @Param("pageable") Pageable pageable);
<!--查询指定行数据-->
    <select id="queryAllByLimit"  resultMap="BaseResultMap">
        select
id, stuId, name, age, sex, address, country, city, salary
        from user
        <where>
            <if test="user.id != null">
                and id = #{user.id}
            </if>
            <if test="user.stuid != null">
                and stuId = #{user.stuid}
            </if>
            <if test="user.name != null and user.name != ''">
                and name = #{user.name}
            </if>
            <if test="user.age != null">
                and age = #{user.age}
            </if>
            <if test="user.sex != null and user.sex != ''">
                and sex = #{user.sex}
            </if>
            <if test="user.address != null and user.address != ''">
                and address = #{user.address}
            </if>
            <if test="user.country != null and user.country != ''">
                and country = #{user.country}
            </if>
            <if test="user.city != null and user.city != ''">
                and city = #{user.city}
            </if>
            <if test="user.salary != null">
                and salary = #{user.salary}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值