[英]groovy.lang.MissingMethodException: No signature of method
I am getting the following error - groovy.lang.MissingMethodException: No signature of method: Script64$_run_closure5_closure7_closure8_closure9_closure10_closure11.doCall() is applicable for argument types: (java.lang.String) values: Possible solutions: doCall(java.lang.Object, java.lang.Object), isCase(java.lang.Object), isCase(java.lang.Object) error at line:我收到以下错误 - groovy.lang.MissingMethodException: No signature of method: Script64$_run_closure5_closure7_closure8_closure9_closure10_closure11.doCall() 适用于参数类型:(java.lang.String) 值:可能的解决方案:doCall(java.lang.Object) , java.lang.Object), isCase(java.lang.Object), isCase(java.lang.Object) 错误行:
Code - EDIT
import groovy.xml.*
List tempList = []
List listgenerated = []
def count = 0
for (a in 0..totalCount-1)
{
//nameList and valueList lists will have all the contents added as below commented pseudo code
/*for (b in 0..50)
{
nameList.add(b,number) // number is some calculated value
valueList.add(b,number)
e.g. nameList=[name1, name2, name3,name4, name5]
valueList =[val1, val2, val3, , val5]
listgenerated should be = [[name1:val1, name2:val2], [name3:val3, name4: , name5:val5]]
} */
tempList = []
for (j in count..nameList.size())
{
count = j
def nameKey = nameList[j]
def value
if (nameKey != null)
{
value = valueList[j]
tempList << [(nameKey) : value]
}
}
count = count
listgenerated.putAt(a,tempList)
number = number +1
}
def process = { binding, element, name ->
if( element[ name ] instanceof Collection ) {
element[ name ].each { n ->
binding."$name"( n )
}
}
else if( element[ name ] ) {
binding."$name"( element[ name ] )
}
}
class Form {
List fields
}
def list = [[ name:'a', val:'1' ], [ name:'b', val :'2', name2:4, xyz:'abc', pqr:'']] //Edited list
f = new Form( fields: list ) //Works fine
f = new Form( fields: listgenerated ) //Gives the above error
String xml = XmlUtil.serialize( new StreamingMarkupBuilder().with { builder ->
builder.bind { binding ->
data {
f.fields.each { fields ->
item {
fields.each { name, value ->
process( binding, fields, name )
}
}
}
}
}
} )
If while creating the "listgenerated" single quotes are added around values it takes it as character and while printing both lists seem different.如果在创建“listgenerated”单引号时在值周围添加它,它将其作为字符,并且在打印两个列表时似乎不同。 I am unable to figure it out what exactly is going wrong.
我无法弄清楚到底出了什么问题。 Any help is appreciated.
任何帮助表示赞赏。 Thanks.
谢谢。 Ref - Groovy: dynamically create XML for collection of objects with collections of properties
Ref - Groovy:为具有属性集合的对象集合动态创建 XML
I believe, where you do:我相信,你在哪里做:
//some loop to add multiple values to the list
listgenerated << name+":"+value
You need to do:你需要做:
//some loop to add multiple values to the list
listgenerated << [ (name): value ]
And add a map to the list rather than a String.并将地图添加到列表而不是字符串。 It's hard to say though as your code example doesn't run without alteration, and I don't know if it's the alterations that are solving the problem
很难说,因为你的代码示例不会在没有改动的情况下运行,我不知道是不是改动解决了问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.