zoukankan      html  css  js  c++  java
  • 【异常】org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter '**' not found.的解决办法

    【异常】org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'showtype' not found. Available parameters are [0, 1, 2, param3, param1, param2]

    解决办法:

    当只有一个参数时,Mapper中可以不使用@Param

    public void insertAdmin(String username);

    但是有多个参数时必须用@Param

    public void insertAdmin(@Param("username")String username,@Param("password")String password);

    扩展:

    @Param 注解在Mybatis中的使用 以及传递参数的两种方式:

    第一种方法(使用@Param注解):

    Dao层的方法:

    void setAgeAndScore(@Param("username") String username,@Params("password") String password,@Params("age") String age,@Params("score")String score);

    对应的Mapper.xml:

    <update id="setAgeAndScore" parameterType="com.***.***.pojo.Student">
      update User
      set age = #{age,jdbcType=VARCHAR},
          score = #{score,jdbcType=VARCHAR}
      where username = #{username,jdbcType=INTEGER}
    and password=#{password,jdbcType=INTEGER}
    </update>

    第二种方法:(不使用@Param注解)

    Dao层的方法:

    void setAgeAndScore(String username,String password,String age,String score);

    对应的Mapper.xml:

    <update id="setAgeAndScore" parameterType="com.***.***.pojo.Student">
      update User
      set age = #{2,jdbcType=VARCHAR},
          score = #{3,jdbcType=VARCHAR}
      where username = #{0,jdbcType=INTEGER}
    and password=#{1,jdbcType=INTEGER}
    </update>
  • 相关阅读:
    PHP多条件模糊查询
    纯干货!一款APP从设计稿到切图过程全方位揭秘(转)
    0532. K-diff Pairs in an Array (M)
    0933. Number of Recent Calls (E)
    0139. Word Break (M)
    0713. Subarray Product Less Than K (M)
    0399. Evaluate Division (M)
    0495. Teemo Attacking (M)
    0179. Largest Number (M)
    0389. Find the Difference (E)
  • 原文地址:https://www.cnblogs.com/zhaijing/p/7121678.html
Copyright © 2011-2022 走看看