您的位置:首页 > 大数据 > 人工智能

Mybatis错误:Parameter 'XXX' not found. Available parameters are [1, 0, param1, param2]

2015-10-17 10:20 701 查看
Spring + Spring mvc + mybatis 下,使用多参数查询语句时,会有标题写的错误:

一下是两种解决办法:

(1).使用提示直接使用0,1代替参数,在xml文件中如:

         <select id="getSender"  parameterType="int" resultType="String">
select sender from homework where subid = #{0} and classid = #{1} and htype = "2"
</select>

        如果写成subid=${subid} and classid=${classid},就会报错。在Dao文件,Service文件里,可以这么写,不用修改:

       //根据subid和classid且htype内容为2,获取发送者的名字(教师)
public List<String> getSender(int subid,int classid)

   

(2)使用Map,将多个参数的输入封装成Map:

         <select id="getSender"  parameterType="Map" resultType="String">

         Dao文件就这么写:

         public List<String> getSender(Map map)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: