Parameter 'xxxx' not found. Available parameters are [list] at java.util.concurrent.FutureTask
2016-04-07 16:07
776 查看
Parameter 'categoryIds' not found. Available parameters are [list] at java.util.concurrent.FutureTask.report(FutureTask.java:122);
xml配置
<select id="getContainInfoByListCategoryIds" resultType="CmsCategoryContainInfoSource">
SELECT
containsInfo.* from cms_category_containinfo containsInfo where containsInfo.categoryid in
<foreach collection="categoryIds" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
对比了一下发现categoryIds在dao中也是这个名字,而且这个参数确实是list,查询下mybatis文档http://www.mybatis.org/mybatis-3/zh/dynamic-sql.html#foreach有如下说明:
动态 SQL 的另外一个常用的必要操作是需要对一个集合进行遍历,通常是在构建 IN 条件语句的时候。比如:
foreach 元素的功能是非常强大的,它允许你指定一个集合,声明可以用在元素体内的集合项和索引变量。它也允许你指定开闭匹配的字符串以及在迭代中间放置分隔符。这个元素是很智能的,因此它不会偶然地附加多余的分隔符。
注意 You can pass
any Iterable object (for example List, Set, etc.), as well as any Map or Array object to foreach as collection parameter. When using an Iterable or Array, index will be the number of current iteration and value item will be the element retrieved in this iteration.
When using a Map (or Collection of Map.Entry objects), index will be the key object and item will be the value object.
注意翻译一下的意思是:你可以传递一个 List 实例或者数组作为参数对象传给 MyBatis。当你这么做的时 候,MyBatis 会自动将它包装在一个 Map 中,用名称在作为键。List 实例将会以“list” 作为键,而数组实例将会以“array”作为键;所以解决办法有两种,第一在配置文件中的item改为list;第二在dao中将参数放入map中,key值任意即可。
Map<String,List> map=new HashMap();
map.put("categoryIds", categoryIds);
return getSqlSession().selectList("CmsCategoryContainInfoSource.getContainInfoByListCategoryIds", map);
解决办法参考:http://chenzhou123520.iteye.com/blog/1921284
xml配置
<select id="getContainInfoByListCategoryIds" resultType="CmsCategoryContainInfoSource">
SELECT
containsInfo.* from cms_category_containinfo containsInfo where containsInfo.categoryid in
<foreach collection="categoryIds" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
对比了一下发现categoryIds在dao中也是这个名字,而且这个参数确实是list,查询下mybatis文档http://www.mybatis.org/mybatis-3/zh/dynamic-sql.html#foreach有如下说明:
foreach
动态 SQL 的另外一个常用的必要操作是需要对一个集合进行遍历,通常是在构建 IN 条件语句的时候。比如:<select id="selectPostIn" resultType="domain.blog.Post"> SELECT * FROM POST P WHERE ID in <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> #{item} </foreach> </select>
foreach 元素的功能是非常强大的,它允许你指定一个集合,声明可以用在元素体内的集合项和索引变量。它也允许你指定开闭匹配的字符串以及在迭代中间放置分隔符。这个元素是很智能的,因此它不会偶然地附加多余的分隔符。
注意 You can pass
any Iterable object (for example List, Set, etc.), as well as any Map or Array object to foreach as collection parameter. When using an Iterable or Array, index will be the number of current iteration and value item will be the element retrieved in this iteration.
When using a Map (or Collection of Map.Entry objects), index will be the key object and item will be the value object.
注意翻译一下的意思是:你可以传递一个 List 实例或者数组作为参数对象传给 MyBatis。当你这么做的时 候,MyBatis 会自动将它包装在一个 Map 中,用名称在作为键。List 实例将会以“list” 作为键,而数组实例将会以“array”作为键;所以解决办法有两种,第一在配置文件中的item改为list;第二在dao中将参数放入map中,key值任意即可。
Map<String,List> map=new HashMap();
map.put("categoryIds", categoryIds);
return getSqlSession().selectList("CmsCategoryContainInfoSource.getContainInfoByListCategoryIds", map);
解决办法参考:http://chenzhou123520.iteye.com/blog/1921284
相关文章推荐
- Java集合类操作优化经验总结
- eclipse
- Java 流(Stream)、文件(File)和IO
- 利用spring-websocket包搭建websocket服务
- 史上最全最强SpringMVC详细示例实战教程
- SpringMVC+Spring4+Mybatis3集成,开发简单Web项目
- java多线程那些事之一
- SpringMVC Controller 介绍
- 升级java1.8及ssh版本中碰到的问题(一)
- springmvc 工作流程及注意点
- java的sqlserver连库信息 包括增删改查 分页查询
- Spring容器
- Spring3 MVC入门实例(示例)Spring3 MVC教程
- java反射机制详解 及 Method.invoke解释
- Java序列化(Serializable)与反序列化
- Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)
- 升级JDK版本后,SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializ
- Caused by: java.net.NoRouteToHostException: No Route to Host from slave2/192.168.10.242 to master:1
- java单例模式详解
- activiti自定义流程之Spring整合activiti-modeler5.16实例(九):历史任务查询