使用mybatis传递String参数时,得不到参数,
解决办法1:在接口参数里加上mybatis中的@param注解
解决办法2:在xml的if里用”_parameter” 代表参数
具体方法网上都有,
要是上述方法没有解决
可以将 String 参数 存入Map 集合中,
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>

本文探讨了在使用MyBatis框架时遇到的参数传递问题,包括如何正确使用@param注解,利用_map_parameter_作为参数占位符,以及将String参数封装到Map集合中的方法,确保SQL查询能够正确接收并处理参数。
1471

被折叠的 条评论
为什么被折叠?



