一、单个参数

mapper

public List<Test> getTestList(String id);

xml

<select id = "getTestList" parameterType = "java.lang.String" resultType = "com.test.Test">
  select t.* from test t where t.id = #{id}
</select>

二、多个参数

1、使用索引

mapper

public List<Test> getTestList(String id, String name);

xml

<select id = "getTestList" resultType = "com.test.Test">
  select t.* from test t where t.id = #{0} and t.name = #{1}
</select>

2、使用Map封装多参数

mapper

public List<Test> getTestList(HashMap map);

xml

<select id = "getTestList" parameterType = "hashmap" resultType = "com.test.Test">
  select t.* from test t where t.id = #{id} and t.name= #{name}
</select>

#{}中的变量名要和map中的key对应。

3、使用注解

mapper

public List<Test> getTestList(@Param("id")int id, @Param("name")int name);

xml

<select id = "getTestList" resultMap = "com.test.Test">
select t.* from test t where t.id = #{id} and t.name = #{name}
</select>

参考-致谢:

1、mingyue1818 ---- MyBatis传入多个参数的问题

MyBatis如何传入多个参数的更多相关文章

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

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

  2. Mybatis 同时传入多个参数和对象

    流程 1,mapper 接口文件使用 @param 注解(一个参数就不用使用注解,多个参数要么使用注解,要么使用数组的方式取值) 2,mapper xml 文件使用 mapper 接口文件传参 pub ...

  3. mybatis如何传入一个list参数

    <!-- 7.2 foreach(循环List<String>参数) - 作为where中in的条件 -->  <select id="getStudentLi ...

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

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

  5. mybatis传入多个参数

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

  6. Mybatis的parameterType传入多个参数

    如果查询的条件有多个的时候,mybatis有三种传入方式: 1.通过注解传入 例如: public interface Mapper(){ public User login(@Param(" ...

  7. MyBatis的传入参数parameterType类型

    1. MyBatis的传入参数parameterType类型分两种 1. 1. 基本数据类型:int,string,long,Date; 1. 2. 复杂数据类型:类和Map 2. 如何获取参数中的值 ...

  8. MyBatis中传入参数parameterType类型详解

    前言 Mybatis的Mapper文件中的select.insert.update.delete元素中有一个parameterType属性,用于对应的mapper接口方法接受的参数类型.本文主要给大家 ...

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

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

随机推荐

  1. WebAPI跨域问题处理

    1.按照https://dzone.com/articles/access-control-allow-origin-header-and-the-aspnet文章所述,在程序中配置允许跨域请求. 但 ...

  2. Redis主从配置以及哨兵模式

    Redis主从模式,应用写master,读slave,减轻master的压力. 配置主结点: daemonize yes port 6379bind 0.0.0.0 pidfile /opt/redi ...

  3. 实验吧flag整理

    奇怪的短信 flagissimple 围在栅栏里的爱ILOVESHIYANBAR. 古典密码flag:CTF{COULDYOUEXCHANGETHEINFORMATION} The Flash-14F ...

  4. zencart简单设置分类链接不同css样式

    includes/templates/模板/sideboxes/tpl_categories.php $content .= '<a class="'.$new_style.'&quo ...

  5. angularJs select ng-selected默认选中遇到的坑

    本人,程序员妹子一枚,,,,名字中有萌字,简称萌妹子哈,,,首先贴出代码: 同样的方式,用ng-selected用来做回显,但是结果让萌妹我很是诧异,第一个“模板类型”那里的select可正常回显,第 ...

  6. Linux性能分析命令工具汇总

    转自:http://rdc.hundsun.com/portal/article/731.html?ref=myread 出于对Linux操作系统的兴趣,以及对底层知识的强烈欲望,因此整理了这篇文章. ...

  7. VS开发框架DevExtreme v19.1全解析!Windows资源管理器UX值得拥有

    行业领先的.NET界面控件DevExpress 正式发布了v19.1版本,本文将以系列文章的方式为大家介绍DevExtreme Complete Subscription v19.1中全新发布的文件管 ...

  8. chattr&lsattr

    chattr 和 lsattr 用来查看和改变文件属性,chmod 只是用来改变文件的读写与可执行权限,而文件的属性控制是由 chattr 来完成 常用用法: chattr +i /home/test ...

  9. Wpf自动滚动效果

    一.思路 1.使用ScrollView的Scroll.ScrollToVerticalOffset(offset)方法进行滚动 2.ScrollView中放置2个ListView,第一个滚动出边界后, ...

  10. selenium环境搭建:Error: could not find java.dll 报错问题

    搭建java环境,参照其他的安装步骤,搭建即可. 问题:出现如下报错信息. Error: could not find java.dll Error: Could not find Java SE R ...