Mybatis 传多个参数
来源:互联网 发布:小米平板刷windows包 编辑:程序博客网 时间:2024/06/06 02:26
第一种:基于注解(推荐)
DAO层的函数方法
public User getUserInfo(@Param("username")String username,@Param("password") String password);
对应的Mapper.xml
<select id="getUserInfo" parameterType="String" resultMap="BaseResultMap">
select * from users WHERE 1=1
<if test="username!='' and username!=null">
and username=#{username}
</if>
<if test="password!='' and password!=null">
and userpassword=#{password}
</if>
</select>
第二种:
DAO层的函数方法
public User getUser(String username,String password);
对应的Mapper.xml
<select id="getUser" parameterType="String" resultMap="BaseResultMap">
select * from users WHERE username = #{0} and userpassword=#{1}
</select>
第三种:
DAO层的函数方法
public User getUserInfo(Map map);
对应的Mapper.xml
<select id="getUserInfo" parameterType="String" resultMap="BaseResultMap">
select * from users WHERE 1=1
<if test="username!='' and username!=null">
and username=#{username}
</if>
<if test="password!='' and password!=null">
and userpassword=#{password}
</if>
</select>
对应的Controller
@RequestMapping(value="redirect",method=RequestMethod.POST)
public String loginInfo(String username,String password) {
// User user=userService.getUser(username, password);
//User user=userService.getUserInfo(username, password);
Map map=new HashMap();
map.put("username", username);
map.put("password", password);
User user=userService.getUserInfo(map);
if(user!=null)
return "redirect:list";
else {
return "login";
}
}
- MyBatis传多个参数
- Mybatis传多个参数
- Mybatis传多个参数
- Mybatis传多个参数解析
- Mybatis传多个参数
- Mybatis传多个参数
- Mybatis传多个参数
- Mybatis传多个参数
- Mybatis传多个参数
- Mybatis传多个参数
- Mybatis传多个参数
- Mybatis传多个参数
- Mybatis传多个参数
- MyBatis之传多个参数
- mybatis传多个参数
- Mybatis传多个参数
- Mybatis 传多个参数
- mybatis传多个参数
- An overview on domain adaptation in neural machine translation
- 网址
- MYSQl中enum类型
- DateUtil
- delphiex8canvas应用
- Mybatis 传多个参数
- NFS write过程1
- Ubuntu下安装libtorrent
- android studio gradle 下载地址
- 超级画板自动推理功能初探
- POJ2991 线段树 区间更新 计算几何
- java原子性与并发
- java interview
- Oracle监控用户索引使用情况,删除无用索引