Mybatis错误:Parameter 'XXX' not found. Available parameters are [1, 0, param1, param2]
2015-10-17 10:20
711 查看
Mybatis错误:Parameter 'XXX' not found. Available parameters are [1, 0, param1, param2]
2015-10-17 10:203768人阅读 评论(0)
收藏
举报
本文章已收录于:
分类:
Jsp(9)
作者同类文章X
版权声明:本文为博主原创文章,未经博主允许不得转载。
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)
相关文章推荐
- C++中的RAII机制 http://www.jellythink.com/archives/101
- AIDL(1)
- RAII惯用法:C++资源管理的利器 http://www.cnblogs.com/hsinwang/articles/214663.html
- CF Round #325 Div2 D. Phillip and Trains
- LeetCode -- Climbing Stairs
- 配置RAID
- golang辟谣之RAII
- Naive Bayesian
- wait_event_interruptible 在驱动中的应用
- TIME_WAIT是什么?
- 系统关键字 retain assign copy
- [Leetcode]Container With Most Water
- 合成存取器中copy和retain的区别
- Codeforces Round #325 (Div. 2) D. Phillip and Trains (BFS)
- E-Mail notifications in MS Dynamics AX 2012
- 查看Wait信息
- Leetcode100: Container With Most Water
- Dubbo错误No provider available for the service
- E - Fibonacci Again(找规律)
- 关于ttserver, mongodb, couchbase. ssdb ,tair, leveldb的一点使用体验