在mybatis通过名字查询数量<select id="findUserCountByBack1" resultType="int" parameterType="User" > select count(*) from onlinemall_user where username like #{username} and userstatus=1; </select>在controller层user.setUsername("%"+username+"%");username已经注入进去,通过查询user.getUsername()能查到name但是int total=userBiz.findUserCount1(user);查询出的total一直是0;dubug提示为:DEBUG [main] - ==> Preparing: select count(*) from onlinemall_user where username like ? and userstatus=1; DEBUG [main] - ==> Parameters: nullTRACE [main] - <== Columns: count(*)TRACE [main] - <== Row: 0DEBUG [main] - <== Total: 10username没成功注入进去,不知道哪儿原因,求解决!
2 回答
慕粉4075985
TA贡献104条经验 获得超33个赞
select count(*) from onlinemall_user where username like concat('%',#{username},'%') and userstatus=1;
试下
添加回答
举报
0/150
提交
取消