我想将验证错误发送回不同的页面(添加),所以我有这个作为我的save
操作:
@Transactional(readOnly = false)
def save(AddDomainCommand command) {
if (command.validate() && session.isLoggedIn && session.publisher) {
// do some stuff
return redirect(controller: 'Widget', action: 'generate')
}
log.info("Validation failed for $command")
respond view: "add", model: [domain: command]
}
它与javax.servlet.ServletException: Could not resolve view with name 'save' in servlet with name 'grailsDispatcherServlet'
如果我打印来自的响应respond
,我会得到null
!所以这就解释了为什么会这样save
,因为这是动作名称的约定。
我需要它返回到它来自 ( add.gsp
) 的视图,但 grailsrespond
为空,因此默认为save.gsp
. 有任何想法吗?