如果查询的条件有多个的时候,mybatis有三种传入方式:

1.通过注解传入

例如:

public interface Mapper(){

    public User login(@Param("username")String username,@Param("password") String password);    

}

@Param注解:将对应形参的值在mapper.xml中传入参数时,指定传入参数的名称。指定在mapper.xml中形参的名字(也就是mapper.xml的配置文件中查询语句的名字)

例如下面标红的部分 

<select id="login"  resultType="user">
select * from user where username=#{username} and password=#{password};
</select>

2.pojo的对象传入

public interface UserMappe{
public User login(User user);
}
<select id="login" resultType="user">
select* from user where username=#{username} and password= #{password};
</select>  

注意:占位符中当参数传递的是pojo的时候,括号中的内容是pojo的属性

3.map传入方式

public interface UserMappe{
public User login(Map<String ,Object> map);
}

  

<select id="login" resultType="user">
select* from user where username=#{username} and password= #{password};
</select> 

  

Mybatis的parameterType传入多个参数的更多相关文章

  1. mybatis之parameterType传递多个参数

    当在查询的时候需要传入多个参数的时候该怎么办呢: 1,封装成一个Model对象,底层HashMap还是一个 User user=new User(); user.setUserName("z ...

  2. mybatis从dao传入多个参数到sqlmap时dao中要使用map或实例对象(如:user)作为参数传入, 否则报错找不到属性getter方法

    23:37 2015-07-02 注意1. 使用mybaits的resultMap查询时, 如果想传入多个参数(比如where 1=1动态多条件查询时)sqlmap文件中对应的方法中, selectL ...

  3. MyBatis的parameterType传入参数类型

    在mybatis映射接口的配置中,有select,insert,update,delete等元素都提到了parameterType的用法,parameterType为输入参数,在配置的时候,配置相应的 ...

  4. Mybatis 向statement传入多个参数

    1.一般情况下可以将多个参数放入Map,让Map作为statement的参数 public void update(@Param("fieldMap") Map<String ...

  5. 每日一记-mybatis碰到的疑惑:String类型可以传入多个参数吗

    碰到一个觉得很疑惑的问题,Mybatis的parameterType为String类型的时候,能够接收多个参数的吗? 背景 初学Mybatis的时候,看的教程和书籍上都是在说基本的数据类型如:int. ...

  6. mybatis传入多个参数

    一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...

  7. Mybatis 接口传入多个参数 xml怎么接收

    mybatis 在接口上传入多个参数 1.如果传入的参数类型一样. Map<String, String> queryDkpayBindBankCidByOriBindAndBankCid ...

  8. MyBatis如何传入多个参数

    一.单个参数 mapper public List<Test> getTestList(String id); xml <select id = "getTestList& ...

  9. 小峰mybatis(2)mybatis传入多个参数等..

    一.mybatis传入多个参数: 前面讲传入多个参数都是使用map,hashmap:key value的形式:-- 项目中开发都建议使用map传参: 比如现在通过两个参数,name和age来查询: 通 ...

随机推荐

  1. 201521123010 《Java程序设计》第7周学习总结

    1. 本周学习总结 以你喜欢的方式(思维导图或其他)归纳总结集合相关内容. 参考资料: XMind 2. 书面作业 ①ArrayList代码分析 1.1 解释ArrayList的contains源代码 ...

  2. 201521123034 《Java程序设计》第3周学习总结

    1. 本章学习总结 看不清点这个:http://naotu.baidu.com/file/c01303326572f7916e506ec5f55270a4 2. 书面作业 1.代码阅读 public ...

  3. 201521145《Java程序设计》第2周学习总结

    1. 本章学习总结 掌握了整数类型(byte short int long char),浮点型(float double),布尔型(boolean)的使用,以及它们的包装类Byte Short Int ...

  4. 201521123087《Java程序设计》第12周学习总结

    1. 本周学习总结 2. 书面作业 将Student对象(属性:int id, String name,int age,double grade)写入文件student.data.从文件读出显示. 1 ...

  5. 微信小程序购物车产品计价

    微信小程序购物车产品计价: 问题:当选中商品,价格累加时会出现无限循环小数 解答:在计算前先parseFloat(变量),再计算的最后使用(变量).toFixed(2)保留两位小数 例如: jiaCa ...

  6. CSS1-3基礎知識

    CSS1-3基礎知識 1.css排版 css在html內排版: <style type='text/css'> 標記名{} .類型名{} #ID名{} 標記名,.類型名,#ID名{} &l ...

  7. macbook 263企业邮箱设置

    第一步:打开邮箱,点击添加账号,选择其他 第二步:填写完整的电子邮件地址和密码 第三步:填写收件服务器(popcom.263xmail.com),发件服务器(smtpcom.263xmail.com)

  8. spring jar包

    org.springframework.aop- 3.0.0.RELEASE--------------------Spring的面向切面编程,提供AOP(面向切面编程)实现 org.springfr ...

  9. Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)ABCD

    A. Arpa and a research in Mexican wave time limit per test 1 second memory limit per test 256 megaby ...

  10. C++PrimerPlus第6版 第四章——复合类型

    1,复合类型主要包含:数组.结构.联合.枚举.类.指针.引用等. 2,数组.长度必须确定.即编译阶段,数组的长度就得确定好.所以只能使用常量(#define.const)声明数组长度.如果使用变量声明 ...