xml
List<Mybatis> selectlist(Map<String,Object> map);
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dao.ImpMapper">
<resultMap id="mybatismap" type="mybatis">
<result column="psw" property="password"/>
</resultMap>
<select id="selectlist" resultMap="mybatismap">
select * from mybatis_1 limit #{index},#{led}
</select>
</mapper>
测试:使用map设置limit
@Test
public void test() {
SqlSession session = Mybatisconfig.getSqlSession();
ImpMapper mapper = session.getMapper(ImpMapper.class);
HashMap<String, Object> map = new HashMap<>();
map.put("index",1);
map.put("led",2);
List<Mybatis> selectlist = mapper.selectlist(map);
for (Object o : selectlist) {
System.out.println(o);
}
session.close();
}