这是一个错误吗?
我的操作方法的中间中的if语句中包含以下块:
withFormat {
json{
render returnMap as JSON
return
}
}
最佳答案
返回值退出“json”闭包,但不退出整个方法。就像有方法与方法一样-您只能弹出一个级别。您需要在块内设置一个标志,然后在外部进行检查,例如
boolean renderedJson = false
...
withFormat {
json{
render returnMap as JSON
renderedJson = true
}
}
...
if (renderedJson) {
return
}
https://stackoverflow.com/questions/6757223/