MyBatis:Parameter Maps collection does not contain value for 的问题解决

本文介绍了一个使用MyBatis实现的登录模块配置案例,详细展示了如何定义resultMap映射和select元素,确保数据库字段与Java对象属性正确匹配,同时实现了用户认证功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

发现问题:

  <resultMap id="BaseResultMap" type="com.team1.vo.User" >
    <id column="userID" property="userid" jdbcType="INTEGER" />
    <result column="roleID" property="roleid" jdbcType="INTEGER" />
    <result column="password" property="password" jdbcType="VARCHAR" />
    <result column="username" property="username" jdbcType="VARCHAR" />
    <result column="sex" property="sex" jdbcType="INTEGER" />
    <result column="age" property="age" jdbcType="INTEGER" />
    <result column="deptID" property="deptid" jdbcType="INTEGER" />
    <result column="position" property="position" jdbcType="VARCHAR" />
    <result column="introduction" property="introduction" jdbcType="VARCHAR" />
    <result column="interests" property="interests" jdbcType="VARCHAR" />
    <result column="phone" property="phone" jdbcType="VARCHAR" />
    <result column="mobilephone" property="mobilephone" jdbcType="VARCHAR" />
    <result column="Email" property="email" jdbcType="VARCHAR" />
    <result column="Address" property="address" jdbcType="VARCHAR" />
  </resultMap>
  
  	<select id="userLogin" parameterMap="BaseResultMap" resultMap="BaseResultMap">
		select * from user where roleid=#{roleid}
		and username=#{username} and password= MD5(#{password})
	</select>
解决问题

  <resultMap id="BaseResultMap" type="com.team1.vo.User" >
    <id column="userID" property="userid" jdbcType="INTEGER" />
    <result column="roleID" property="roleid" jdbcType="INTEGER" />
    <result column="password" property="password" jdbcType="VARCHAR" />
    <result column="username" property="username" jdbcType="VARCHAR" />
    <result column="sex" property="sex" jdbcType="INTEGER" />
    <result column="age" property="age" jdbcType="INTEGER" />
    <result column="deptID" property="deptid" jdbcType="INTEGER" />
    <result column="position" property="position" jdbcType="VARCHAR" />
    <result column="introduction" property="introduction" jdbcType="VARCHAR" />
    <result column="interests" property="interests" jdbcType="VARCHAR" />
    <result column="phone" property="phone" jdbcType="VARCHAR" />
    <result column="mobilephone" property="mobilephone" jdbcType="VARCHAR" />
    <result column="Email" property="email" jdbcType="VARCHAR" />
    <result column="Address" property="address" jdbcType="VARCHAR" />
  </resultMap>
  
  	<select id="userLogin" parameterType="User" resultMap="BaseResultMap">
		select * from user where roleid=#{roleid}
		and username=#{username} and password= MD5(#{password})
	</select>

parammeterMap="BaseResultMap" -------》parameterType="com.demo.sys.entity.Module"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值