1、多个类型相同的参数,可以放入Map里面带过去,如:
service:
HashMap< String, String> map=new HashMap<String, String>(); map.put("id", user.getId()); map.put("pwd", newpwd); int a=dao.upPwd(map);
dao:
int upPwd(HashMap<String, String> map);
<!--修改密码--> <update id="upPwd" parameterType="Map">update user set pwd=#{pwd} where id=#{id}</update>
2、不同类型的参数,可以加@Param注解,如:
dao:
int updateUserRoles(@Param("uid")String uid, @Param("rlist")List<String> ridList);
<!--批量插入用户权限--> <insert id="updateUserRoles" > insert into userrole (rid,uid) values <foreach collection="rlist" item="item" index="index" separator=",">(#{item},#{uid})</foreach> </insert>
3、单个参数:xml里这个参数前加上下划线即可,如:
dao:
String getRidByName(String name);
<!--根据name查询rid--> <select id="getRidByName" resultType="String">select rid from role where name=#{_name}</select>