mybatis xml的配置:
<select id="slectByPage" resultType="Ad">
select id, title, img_file_name, link, weight
from ad
<where>
<if test="title!=null and title!=''">
title like "%" #{title} "%"
</if>
</where>
<!--权重如果一样的话 ,就按照id 进行排序-->
order by weight desc,id
</select>
错误地方:是在 进行验证的报错的,
解决方法:1.在dao层方法参数添加(@Param(value=“title”)
2.在参数只有一个的时候利用mybatis的内置参数 代表单个参数
if中的title改为_parameter