傳入多個參數的方法
#{index} 表示第幾個參數
<update id="updateCourseStudent_id" parameterType="int"> update course2 set student_id=#{0} where cid=#{1} </update>
通過註解
接口: public void updateCourseStudent_id2(@Param("student_id") long sid,@Param("cid") long cid); xml: <update id="updateCourseStudent_id2" parameterType="long"> update course2 set student_id=#{student_id} where cid=#{cid} </update>
通過Map的方式傳遞
map中key的名字就是在#{}中使用的那個
<update id="updateCourseStudent_id2" parameterType="long"> update course2 set student_id=#{key1} where cid=#{key2} </update>
創建javaBean,添加get/set,將參數作爲javaBean的屬性