解决方法:
@MyBatisDao public interface OfficeDao extends TreeDao<Office> { List<Office> findCompanyNameList(@Param("name")String name); }
<select id="findCompanyNameList" parameterType="java.lang.String" resultType="com.pds.modules.sys.entity.Office"> SELECT id,name FROM sys_office where o.del_flag = '1' <if test="name!= null and name!= ''"> AND name LIKE concat('%',#{name},'%') </if> </select>
<select id="findCompanyNameList" parameterType="java.lang.String" resultType="com.pds.modules.sys.entity.Office"> SELECT id,name FROM sys_office where o.del_flag = '1' <if test="_parameter!= null and _parameter!= ''"> AND name LIKE concat('%',#{name},'%') </if> </select>
<select id="findByName" parameterType="string" resultType="com.domain.entity.FactoryEntity"> SELECT * FROM T_FACTORY WHERE F_NAME LIKE "%${_parameter}%" </select>
可以看出,_parameter不能区分多个参数,而@param能。所以@param能传多个这样的参数
Map map=new HashMap(); map.put("condition",condition); List list=bookMapper.bookList(map);
<select id="bookList" parameterType="map" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from book <if test="condition!= null"> where bname like '%${condition}%' or author like '%${condition}%' </if> </select>
参照: