解決Parameter 'username' not found. Available parameters are [0, 1, param1, param2]

問題描述

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}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章