當前位置:編程學習大全網 - 網站源碼 - 如何解決SpringMVC+mybatis框架錯誤的問題?

如何解決SpringMVC+mybatis框架錯誤的問題?

出現這個錯誤是由於在執行sql的時候無法匹配sql語句的通配符造成的,有兩個解決方法

具體步驟

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

出現這個錯誤是由於在執行sql的時候無法匹配sql語句的通配符造成的,有兩個解決方法。

1.在對應dao的xml文件的sql語句要這樣寫

<select id="findByUsernameAndPassword" resultType="com.lzcc.model.User"> select * from user where username = #{0} and password = #{1};</select>123

2.在dao接口的方法中的參數中添加@param註解

List<User> findByUsernameAndPassword(@Param("username") String username,@Param("password") String password) throws SQLException;1

3.如果上述兩點都正常有可能是springmvc把靜態資源給攔截了。要在springmvc的配置文件中加入以下代碼:

<mvc:resources?location="/images/"?mapping="/images/**"/>?

<mvc:resources?location="/js/"?mapping="/js/**"/>?

<mvc:resources?location="/css"?mapping="/css/**"/>

  • 上一篇:js11時間繼電器指針式怎麽調時間
  • 下一篇:夏季減腰收腹的方法
  • copyright 2024編程學習大全網