https://www.5ceo.cn 更多技术博文点击查看
<select id="find" parameterType="com.sfbm.carmall.persistent.model.brand.Brand"
resultType="map">SELECT
t.brand_id brandId,
t.brand_name brandName,
t.description
description,
t.url url
FROM
t_brand t where t.delFlag=0
<if test="brand_name!=null and ''!=brand_name ">
and t.brand_name like '%${brand_name}%'
</if>
</select>
为map集合,参数类型可以为,string,entity,以及map
1.如果参数类型为string 那么 brand_name like '%${value}%'此处必须为value,如果为其他属性将报no Getter的错误。
2.如果是对象entity,则parameterType必须是“package.class”的格式,并且 "%${}%"中的属性必须是entity中的属性。
3.如果参数为map,则parameterType是Java.util.Map,并且"%${}%"中的属性必须是map中的key。
*如果jsp页面用对象传值到control,则jsp页面应该这样写:
<input name="brand_name"> brand_name必须是entity中的属性。并且不用entity.brand_name这样的方式
*control中必须用@ModelAttribute绑定该对象
@ModelAttribute("entity") Entity entity
模糊查询时,%${brand_name}% {}前面不能是#,必须是${}
或者Oracle 用concat(concat('%',#{}),'%')mysql:concat('%',#{},‘%’)