import groovy.xml.MarkupBuilder
class Foo {
Foo() {}
String boo() {
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.records() {
car(name:'HSV Maloo', make:'Holden', year:2006) {
country('Australia')
record(type:'speed', 'Production Pickup Truck with speed of 271kph')
}
}
println writer
}
def methodMissing(String methodName, args) {
println "Get called"
}
}
Foo a = new Foo()
a.boo()
结果:
Get called
<records />
不执行methodMissing()
,结果:
<records>
<car name='HSV Maloo' make='Holden' year='2006'>
<country>Australia</country>
<record type='speed'>Production Pickup Truck with speed of 271kph</record>
</car>
</records>
我现在正在挠头流血,我在这里错过了什么?