SpringBoot+MyBatis实现多参数查询时,报错
解决办法:
-
利用参数出现的顺序
<select id="select" resultType="model.User"> select * from `user` where name = #{arg0} and age =#{arg1} </select>
使用参数出现的顺序号码引用参数,第一个参数用arg0或param1表示,第二个参数用arg1或param2表示,以此类推。
-
使用注解
给接口中方法的参数加上注解public interface UserMapper { List<User> select(@Param("name") String name,@Param("age") byte age); }
数据库查询xml保持不变
<select id="select" resultType="model.User"> select * from `user` where name = #{id} and age =#{age} </select>