在MyBatis中,可以使用ResultMap来获取查询结果中列的值。具体步骤如下:
<resultMap id="userResultMap" type="User">
<id property="id" column="user_id"/>
<result property="username" column="user_name"/>
<result property="email" column="user_email"/>
</resultMap>
<select id="selectUser" resultMap="userResultMap">
SELECT user_id, user_name, user_email
FROM users
WHERE user_id = #{id}
</select>
User user = sqlSession.selectOne("selectUser", 1);
System.out.println("User ID: " + user.getId());
System.out.println("Username: " + user.getUsername());
System.out.println("Email: " + user.getEmail());
通过以上步骤,就可以在MyBatis中获取查询结果中列的值。