![MyBatis 传一个类型为String的参数时常见问题及解决方法 MyBatis 传一个类型为String的参数时常见问题及解决方法](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
MyBatis要求如果参数为String的话,不管接口方法的形参是什么,在Mapper.xml中引用时需要改变为_parameter才能识别 :
<select id=
"selectByIp"
parameterType=
"string"
resultType=
"voteIP"
>
select *
form vote
<where>
<
if
test =
"_parameter!= null"
>
ip=#{_parameter}
</
if
>
</where>
</select>