一、参数索引方式
Dao层
2 Public User selectUser(String name,String area);
对应XML文件
1 <select id="selectUser" resultMap="BaseResultMap"> 2 select * from user_user_t where user_name = #{0} and user_area=#{1} 3 </select>
二、使用Map传递多参数
Dao层
1 Public User selectUser(Map paramMap);
对应xml文件
1 <select id=" selectUser" resultMap="BaseResultMap"> 2 select * from user_user_t where user_name = #{userName,jdbcType=VARCHAR} and user_area=#{userArea,jdbcType=VARCHAR} 3 </select>
Service层调用
1 Private User xxxSelectUser(){ 2 Map paramMap=new hashMap(); 3 paramMap.put(“userName”,”对应具体的参数值”); 4 paramMap.put(“userArea”,”对应具体的参数值”); 5 User user=xxx. selectUser(paramMap);}
三、注解
Dao层
Public User selectUser(@param(“userName”)Stringname,@param(“userArea”)String area);
对应XML文件
1 <select id=" selectUser" resultMap="BaseResultMap"> 2 select * from user_user_t where user_name = #{userName,jdbcType=VARCHAR} and user_area=#{userArea,jdbcType=VARCHAR} 3 </select>