mybatis and mapper.xml

今天的项目ssm,写完mapper.xml后报错,如下

Caused by: org.apache.ibatis.binding.BindingException: Parameter 'usernane' not found. Available parameters are [1, 0, param1, param2]

解决方法: 

第1种,dao中相关方法加注解

User checkuser(@Param("username")String username, @Param("password")String password);

第2种,直接修改sql:

select * from user where username=#{username} and password=#{password}

改为:

select * from user where username=#{0} and password=#{1}


猜你喜欢

转载自blog.csdn.net/hanguihb/article/details/53470974