mybatis dao层到xml映射文件正确的传参数方式
时间: 2020-08-04来源:OSCHINA
前景提要
根据参数名字映射 public interface UserDao extends BaseMapper<User> { List<User> listUser ( @Param ( "userName" ) String userName , @Param ( "password" ) String password) ; }
根据@Param("userName") 中的名称与xml映射文件的#{userName}名称对应,此时在select中可以不用写paramType <select id ="listUser" resultType ="com.reuse.customer.entity.User" > select * from user <where> <if test ="userName!=null and userName.trim()!=''" > user_name=#{userName} </if> <if test ="password!=null and password.trim()!=''" > and password=#{password} </if> </where> </select>
注意在<where>条件语句前面不要随意写注释,否则容易报错。

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行