mapper
1 <!--传递map的key --> 2 <insert id="addUser2" parameterType="map"> 3 insert into mybatis.user (id , name ,password ) values(#{userid},#{username},#{password}); 4 </insert>
测试
1 @Test 2 public void addUser2(){ 3 SqlSession sqlSession = MybatisUtils.getSession(); 4 //sqlSession获取mapper 5 UserMapper mapper= sqlSession.getMapper(UserMapper.class); 6 Map<String, Object> map = new HashMap<String, Object>(); 7 map.put("userid",5); 8 map.put("username","hello"); 9 map.put("password","123456"); 10 mapper.addUser2(map); 11 sqlSession.commit(); 12 sqlSession.close(); 13 }