第一种:#{0}或者是#{arg0} 看是否是3.4.2及之前#{0} 或者之后#{arg0} 

dao:
/**
* 添加,传递多个参数 * @param dname * @param loc * @return */ int addA(String dname,String loc); mapper: <!-- 添加,多个参数 3.4.2版本之前#{0} 之后#{arg0} https://www.cnblogs.com/zhangmingcheng/p/9922236.html--> <insert > insert into dept values(null,#{arg0},#{arg1}) </insert>

第二种:使用 @param 注解

 dao:
       /**
     * 添加,@Param传递多个参数
     * @param dname
     * @param loc
     * @return
     */
    int addB(@Param("deptName") String dname,@Param("loc") String loc);
mapper:
<!--添加,@Param传递多个参数-->
<insert > insert into dept values(null,#{deptName},#{loc}) </insert>

 

在mapper中传递多个参数

第三种:多个参数封装成map或者是实体

 dao方法:
   /**
     * 添加
     * @param dept
     * @return
     */
    int add(Dept dept);
    mapper:
   <!--添加部门并返回自增ID-->
    <insert >
        insert into dept values(null,#{deptName},#{loc})
    </insert>

相关文章:

  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
  • 2022-01-22
  • 2021-06-02
  • 2022-01-18
  • 2021-10-19
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
  • 2021-09-25
相关资源
相似解决方案