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 ...
随机推荐
- js-textarea文本换行符处理,Java后端以及js前端如何处理
方法一:后台处理 TextArea的换行符处理 TextArea文本转换为Html:写入数据库时使用 js获取了textArea的文本内容之后,器内容含有换行,空格,制表符之类的字符,但是js字符串不 ...
- spring源码学习——spring整体架构和设计理念
Spring是在Rod Johnson的<Expert One-On-One J2EE Development and Design >的基础上衍生而来的.主要目的是通过使用基本的java ...
- [BAT] 通过命令行窗口重启或关闭远程电脑
在命令行窗口输入“shutdown -s”, 关闭远程计算机 在命令行窗口输入“shutdown -r”, 重新启动远程计算机
- easyui-tabs扩展根据自定义属性打开页签
.增加扩展 <script type="text/javascript" > /** * @author {kexb} easyui-tab扩展根据id切换页面 */ ...
- CentOS/RedHat安装Python3
CentOS/RedHat安装Python3 摘自:https://blog.csdn.net/mvpboss1004/article/details/79377019 CentOS/RedHat默认 ...
- ubuntu14.04下安装qt5
1.sudo apt-get install build-essential 2.先打开终端快捷键ctrl+t 3. 然后输入: sudo apt-get install cmake qt5-defa ...
- spring 获取 WebApplicationContext的几种方法
spring 获取 WebApplicationContext的几种方法 使用ContextLoader WebApplicationContext webApplicationContext = C ...
- java中Integer常量池
我们先看一个关于Integer的例子 public static void main(String[] args) { // TeODO Auto-generated method stu Integ ...
- 基于Xcode5的本地化
一.程序名国际化 1.首先添加应用对多语言支持的国际化文件 点击工程根目录,然后选择PROJECT下的项目,然后选择Info选项卡,在底部可以看到Localizations,点击“+”号,可以 ...
- sublime Text2常见插件介绍
zen coding 一种快速编写HTML/CSS代码的方法,已改名为Emmet,并且搭建了一个新的网站:docs.emmet.io Sublime Text 2安装插件Emmet后,打开sublim ...