记录一下mybatis实现模糊查询的实现
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.ruiskey.mapper.UserMapper">
<select id="getPage" resultType="org.ruiskey.entity.User">
select * from user where username like '%${username}%' limit #{pageNum}, #{pageSize}
</select>
</mapper>
注意这里是%${username}%
, 而不是%#{username}%