在用mybatis 时,出现以下错误:
Parameter 'book' not found. Available parameters are [0, 1, param1, param2]
原因是 在mapper 映射的函数参数没有加 @param(“book”)
错误的:
List<Book> selectBySchool(Page<Book> page, BookExample example, Book book);
正确的:
List<Book> selectBySchool(Page<Book> page, BookExample example,@Param("book") Book book);
在xml 里 这样写
<select id="selectBySchool" parameterType="com.xuezhixin.mls.web.model.Book" resultMap="BaseResultMap">
select * from book where school=#{book.school}
</select>