博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MyBatis传入多个参数笔记(一)
阅读量:7121 次
发布时间:2019-06-28

本文共 1013 字,大约阅读时间需要 3 分钟。

一、传入一个参数

1、Controller里面的方法
selectUser(@Param("user_id") int user_id)复制代码
2、Dao层的方法
public List
selectInfo(int userId) { List
userInfos = sqlSessionTemplate.selectList("com.ruolan.bean.StudentMapper.selectUser",userId); return userInfos; }复制代码
3、Mapper里面进行参数的取值
复制代码

二、传入多个参数

1、Controller里面的方法
selectUserInfo(@Param("index") int index, @Param("listrow") int listrow)复制代码
2、Dao层的方法,拼接参数成map
public List
selectUserInfo(int index,int listrow) { Map parmars = new HashMap<>(); //这里index和listrow 就是mapper里面要取的key值 parmars.put("index", index); parmars.put("listrow", listrow); List
userInfos = sqlSessionTemplate.selectList("com.ruolan.bean.StudentMapper.selectUserInfo",parmars); return userInfos; }复制代码
3、Mapper里面进行参数的取值
复制代码

转载地址:http://rhiel.baihongyu.com/

你可能感兴趣的文章
最近找到了一个免费的python教程,两周学会了python开发【内附学习视频】
查看>>
JHipster生成微服务架构的应用栈(三)- 业务微服务示例
查看>>
php用curl获取远端网页内容
查看>>
selenium+python谷歌驱动配置
查看>>
oralce的function处理考勤时间节点以及计算工作时间
查看>>
(三)、一步一步学GTK+之布局
查看>>
43. ExtJs控件属性配置详细
查看>>
ros名称、命名空间和重映射
查看>>
系统进程查看 --- 微软官方出品
查看>>
Python 第三方模块安装出现的问题和解决方案.
查看>>
实验1
查看>>
CF915E Physical Education Lessons(珂朵莉树)
查看>>
洛谷P5050 【模板】多项式多点求值
查看>>
第十章:基本数据结构(2)
查看>>
php处理管道文件流
查看>>
Centos 6 搭建安装 Gitlab
查看>>
2012.02.13(rtsp)
查看>>
关于设置安卓屏幕的显示方向
查看>>
面试题10-二进制中1的个数
查看>>
cmd 查看域名对应的 IP
查看>>