Grails-将映射从服务迭代到csv文件-Groovy

Grails-将映射从服务迭代到csv文件-Groovy,csv,grails,groovy,Csv,Grails,Groovy,如何将结果映射迭代到CSV文件中? 当我在控制器块中有我的方法时,我可以很好地迭代它们,但是如果我将其放入服务并调用,它将无法识别键并返回空行。(无法识别it.column_1。) 谢谢你们 啊,我解决了问题。我在服务中有[resultRows:resultRows]。我删除了该行,并将其放在控制器def resultRows行的正下方 def export(Person personInstance) { def resultRows = someService.result(pers

如何将结果映射迭代到CSV文件中? 当我在控制器块中有我的方法时,我可以很好地迭代它们,但是如果我将其放入服务并调用,它将无法识别键并返回空行。(无法识别it.column_1。)


谢谢你们

啊,我解决了问题。我在服务中有[resultRows:resultRows]。我删除了该行,并将其放在控制器def resultRows行的正下方

def export(Person personInstance) {
    def resultRows = someService.result(personInstance)
    [resultRows:resultRows]
....
}
def export(Person personInstance) {
    def resultRows = someService.result(personInstance)
    [resultRows:resultRows]
....
}

谢谢你们

请显示产生错误的代码。无法识别列_1。是否有输入错误?“resultRows.each(){code'…应该是'resultRows.each'{code'?@jayan他们是一样的,但是你是对的,你的方式更习惯于groovy:-)什么是
someService.result
返回?你试过调试它吗?@tim_yates:谢谢。你不应该在你自己的问题上发布答案。如果你找到了解决方案,你可以编辑你的问题并把它放在那里。@BearArmatis,相当于c相反。StackOverflow明确鼓励在你有正确答案时回答你自己的问题。这是常见问题解答的链接。感谢你的启发。我真的不知道。如果你放弃在这里投票和在另一个问题上投票。你现在有50个问题希望可以发表评论now@vahid,谢谢。你真好。
def export(Person personInstance) {
    def resultRows = someService.result(personInstance)
    [resultRows:resultRows]
....
}
def export(Person personInstance) {
    def resultRows = someService.result(personInstance)
    [resultRows:resultRows]
....
}