第一种:
Dao层的方法
Public User selectUser(String name,String password);
<select id="selectUser" resultMap="BaseResultMap">
select * from user_user_t where user_name = #{0} and user_password=#{1}
</select>
第二种:
该方法采用Map传多参数
Dao层的方法
Public User selectUser(Map paramMap);
<select id=" selectUser" resultMap="BaseResultMap">
select * from user_user_t where user_name = #{userName,jdbcType=VARCHAR} and user_password=#{userPassword,jdbcType=VARCHAR}
</select>
Service层调用
public User xxxSelectUser(){
Map paramMap=new hashMap();
paramMap.put(“userName”,”对应具体的参数值”);
paramMap.put(“userPassword”,”对应具体的参数值”);
User user=xxx. selectUser(paramMap);}
第三种:
Dao层的方法
Public User selectUser(@param(“userName”)Stringname,@param(“userpassword”)String password);
<select id=" selectUser" resultMap="BaseResultMap">
select * from user_user_t where user_name = #{userName,jdbcType=VARCHAR} and user_password=#{userPassword,jdbcType=VARCHAR}
</select>Public User selectUser(@param(“userName”)Stringname,@param(“userpassword”)String password);
<select id=" selectUser" resultMap="BaseResultMap">
select * from user_user_t where user_name = #{userName,jdbcType=VARCHAR} and user_password=#{userPassword,jdbcType=VARCHAR}
</select>
Ps:如果要传对象请参考---》http://blog.youkuaiyun.com/shasiqq/article/details/51222077
转载地址:http://blog.youkuaiyun.com/shasiqq/article/details/51305666
MyBatis多参数查询
本文介绍了使用MyBatis进行数据库查询时的三种方法:直接使用字符串和密码作为参数、通过Map传递多个参数以及使用注解指定参数名称。每种方法都提供了详细的代码示例。
385

被折叠的 条评论
为什么被折叠?



