ibatis遍历数组:ParameterObject or property was not a Collection, Array or Iterator.
这个问题在使用ibatis的<iterate></iterate>时出现的,很简单,但是蛋疼了很久,记下来
首先从错误提示看,明显意思是你给出ibatis的参数不对路,人家不认识,我也是被这个提示误导了
1.先来个小学的
//传入的参数只有数组/集合/迭代器的时候
public List findall(SqlMapClient sqlMap, String[] ids) throws SQLException{
return sqlMap.queryForList("findall",ids)
}
<!--传入值唯一数组,所以甚至这么干就行-->
<statement id="findall" resultClass="..User">
select * from user_table where id in
<iterate open="(" close=")" conjunction=",">
#[]#
</iterate>
</statement> <!--r如果是list需要加个参数类型,然后指定下-->
<statement id="findall" resultClass="..User" parameterClass="java.util.List">
select * from user_table where id in
<iterate open="(" close=")" conjunction=",">
#ids[]#
</iterate>
</statement>
2.来个中学的(倒在这里了)
//传入对象,那么User中有个属性叫爱好 hobbies[] 同时form传递来的字段叫hobby
public List findAll(SqlMapClient sqlMap,User user){
return sqlMap.queryForList("findall",user); }
//
<statement id="findall" parameterClass=="...User" resultClass="...User">
select * from table_user where 1=1
<isNotEmpty property="org_ids" prepend="and">
hobby in
<iterate property="hobbies" open="(" close=")" conjunction=",">
#hobbies[]#
</iterate>
</isNotEmpty>
</statement>
3.还没用过大学的map遍历 对象遍历 就不说了
慢慢看这个
http://hongzhguan.iteye.com/blog/1222353
ibatis遍历数组:ParameterObject or property was not a Collection, Array or Iterator.的更多相关文章
- JS中遍历数组、对象的方式
1.标准的for循环遍历数组 //不打印自定义属性和继承属性 var array = [1,2,3]; for (var i = 0; i < array.length; i++) { cons ...
- PHP遍历数组的几种方法
这三种方法中效率最高的是使用foreach语句遍历数组.从PHP4开始就引入了foreach结构,是PHP中专门为遍历数组而设计的语句,推荐大家使用.先分别介绍这几种方法 PHP中遍历数组 ...
- PHP 遍历数组for foreach while
以下是使用foreach while for 三种循环展示遍历数组的概念 1:foreach( ) <?php $a = array('hank','mike','lucy'); forea ...
- Struts2的OGNL遍历数组、List、简单的Map
一.简介 <s:iterator />可以遍历 数据栈里面的任何数组,集合等等 在使用这个标签的时候有三个属性值得我们关注 1. value属性:可选的属性,value属性是指一 ...
- webwork遍历数组标签
WebWork中提供了一个<ww:iterator></ww:iterator>标签用于遍历数组. 01 如果数组中是普通类型,比如String.int等类型,可以通过标签中的 ...
- *使用while循环遍历数组创建索引和自增索引值
package com.chongrui.test;/* *使用while循环遍历数组 * * * */public class test { public static void main ...
- nodejs 遍历数组的两种方法
var array = [1,2,3]; array.forEach(function(v,i,a){ console.log(v); console.log(i); console.log(a); ...
- 原生js使用forEach()与jquery使用each遍历数组,return false 的区别
原生js使用forEach()与jquery使用each()遍历数组,return false 的区别: 1.使用each()遍历数组a,如下: var a=[20,21,22,23,24]; $.e ...
- js中数组遍历for与for in区别(强烈建议不要使用for in遍历数组)
js中遍历数组的有两种方式 var array=['a'] //标准的for循环 for(var i=1;i<array.length;i++){ alert(array[i]) } //for ...
随机推荐
- android-tip-关于SurfaceView的使用
1. SurfaceView的创建和销毁 当SurfaceView隐藏时,SurfaceView被销毁,此时会调用SurfaceHolder.Callback.surfaceDestroyed ...
- Use formatter to format your JAVA code
In order to make the codes looks unified and make it easy to understand, it's better to use the same ...
- Perl 学习笔记-目标操作
1.在目录树中移动. 程序运行时会以当前工作目录作为相对路径的起点, 可以使用 chdir 操作符改变当前目录: chdir "/etc" or die "Can't ...
- ERROR: from PIL import Image ImportError: No module named PIL
ERROR: from PIL import Image ImportError: No module named PIL 到 http://www.pythonware.com/products/p ...
- pig(数据流语言和编译器)学习https://www.w3cschool.cn/apache_pig/apache_pig_execution.html
当我们配置了hadoop集群执行的时候 可以通过命令ls进行查看 存储语法 STORE Relation_name INTO ' required_directory_path ' [USING fu ...
- Linux删除(清空)正在运行的应用日志文件内容
在测试环境定位问题时,如果发现日志文件内容太多或太大,有时需要删除该日志,如Tomcat,Nginx日志.以前每次都是先rm -rf ***.log,然后重启应用.直到后来发现了以下命令,原来可以不用 ...
- MVC4 View 的呈现
一 ActionResult: 1. EmptyResult: Action方法返回的ActionResult对象被ActionInvoker 调用以实现对当前请求的响应,不论Action方法是否具有 ...
- Android-SDCard外部存储文件读写
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses ...
- Replication--将LSN转换成16进制
在复制中经常会使用到16进制的LSN,但在日志fn_dblog中的LSN是数字形式,于是从网上找到以下转换函数CREATE FUNCTION dbo.fn_convertnumericlsntobin ...
- Replication--使用MSlogreader_history查看日志读起的延迟和事务命令
--======================================================================== MSlogreader_history 表存放本地 ...