1. Multiple parameters of the same type can be brought into the Map, such as:
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);
<!--Change password--> <update id="upPwd" parameterType="Map">update user set pwd=#{pwd} where id=#{id}</update>
2. Different types of parameters can be annotated with @Param, such as:
dao:
int updateUserRoles(@Param("uid")String uid, @Param("rlist")List<String> ridList);
<!--Batch insert user permissions--> <insert id="updateUserRoles" > insert into userrole (rid,uid) values <foreach collection="rlist" item="item" index="index" separator=",">(#{item},#{uid})</foreach> </insert>
3. Single parameter: add an underscore before this parameter in xml, such as:
dao:
String getRidByName(String name);
<!--Query rid by name--> <select id="getRidByName" resultType="String">select rid from role where name=#{_name}</select>