在我们的控制器中试图循环,我们检查的每个数字都在一个数组中。完成检查后,我们会添加静态和动态值以形成消息。现在消息的静态部分正确形成了STATICDATA,你可以在DYNDATA中看到数组,在.each等过程中它似乎保持STATICVALUE为第一次设置的整个值?我希望它使用数组中的正确信息进行更新。
numbers.each{
println "Current number in MessageData: " + dynData[messIndex*(messLength-1)] + " CurrentNumber: " + it
def currIndex = (messIndex*(messLength-1))
println "dynData Index: " + currIndex
if (dynData[currIndex].toString() == ("["+it+"]")) {
//The number for this message matches the number in the numbers list
println "messIndex: " + messIndex
println "Static Data from session: " + statData
statData = session.getAttribute("StaticData")
//HERE I WANT IT TO BE RESET TO [Name is a , , with a chest size of , ] but it appears to hold the variables man and 32d from the first instance
def dyni = currIndex+1
for (int i=0; i < statData.size();i++){
println "STATDATA["+i+"]="+statData[i]
if (statData[i] == ""){
println "dynData["+dyni+"]="+dynData[dyni]
statData[i]=dynData[dyni].toString()
println "statData["+i+"] = "+statData[i]
println "dynData["+dyni+"]= "+dynData[dyni]
dyni++
}
}
println "OUR MESSAGE STRING WILL BE: " + statData
statData[] = []
println "Stat Data cleared ?? : " + statData
println "statData: " + statData
messIndex++
}
def numbersSave = upload
.addToNumbers(new MobileNos(number: it))
.save(flush:true)
}
输出
DYNDATA::: [[number1], [man], [32d], [number2], [unsure], [38DDDDD], [number3], [woman], [36b], [invalidcolumn]]
STATICDATA::: [Name is a , , with a chest size of , ]
Current number in MessageData: [447751694949] CurrentNumber: 447751694949
dynData Index: 0
messIndex: 0
Static Data from session: [Name is a , , with a chest size of , ]
STATDATA[0]=Name is a
STATDATA[1]=
dynData[1]=[man]
statData[1] = [man]
dynData[1]= [man]
STATDATA[2]=with a chest size of
STATDATA[3]=
dynData[2]=[32d]
statData[3] = [32d]
dynData[2]= [32d]
OUR MESSAGE STRING WILL BE: [Name is a , [man], with a chest size of , [32d]]
Stat Data cleared ?? : [Name is a , [man], with a chest size of , [32d]]
statData: [Name is a , [man], with a chest size of , [32d]]
Current number in MessageData: [447766023483] CurrentNumber: 447766023483
dynData Index: 3
messIndex: 1
Static Data from session: [Name is a , [man], with a chest size of , [32d]]
STATDATA[0]=Name is a
STATDATA[1]=[man]
STATDATA[2]=with a chest size of
STATDATA[3]=[32d]
OUR MESSAGE STRING WILL BE: [Name is a , [man], with a chest size of , [32d]]
Stat Data cleared ?? : [Name is a , [man], with a chest size of , [32d]]
statData: [Name is a , [man], with a chest size of , [32d]]
Current number in MessageData: [447751699996] CurrentNumber: 447751699996
dynData Index: 6
messIndex: 2
Static Data from session: [Name is a , [man], with a chest size of , [32d]]
STATDATA[0]=Name is a
STATDATA[1]=[man]
STATDATA[2]=with a chest size of
STATDATA[3]=[32d]
OUR MESSAGE STRING WILL BE: [Name is a , [man], with a chest size of , [32d]]
Stat Data cleared ?? : [Name is a , [man], with a chest size of , [32d]]
statData: [Name is a , [man], with a chest size of , [32d]]
你可以看到,在第一次之后它只保留了值和32d而不是像我希望的那样向下移动数组...就像它记住了值,即使我试图在结束时清除它们循环。
请帮助:D