问题描述
2020-03-24 11:04:56.964 ERROR 11092 --- [nio-8092-exec-3] o.a.c.c.C.[.[.[.[dispatcherServlet] :
Servlet.service() for servlet [dispatcherServlet] in context with path [/shop] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'username' not found. Available parameters are [0, 1, param1, param2]] with root cause
Mybatis传递参数是按位置传递的,也就是说Dao层的接口中需要这样写:
Books login(@Param("username")String username, @Param("password")String password);
对应的XML中使用参数是这样的
select * from employee where name = #{username} and password = #{password}