SSM框架之Mybatis同时传入多个对象及普通参数

2022-08-27 10:27:31

当传入多个文件时,mapper接口文件的方法参数要使用@param(“xx”)注释。

例子:

mapper:

//Student是对象,age是String类型。
int getPojo(@param("student") Student student, @param("age") String age );

xml:

<select id="getStudent" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from student
    where 1 = 1
    <!-- 使用参数一(是个自己的对象) -->
    <if test="student.id != null">
        and id = #{student.id}
    </if>
    <!-- 使用参数二 String类型 -->
    <if test="age!= null">
        and age = #{age}
    </if>
</select>
  • 作者:L聪聪聪
  • 原文链接:https://blog.csdn.net/lcgoing/article/details/84979725
    更新时间:2022-08-27 10:27:31