我是Grails新手,对于大多数人来说,我有一个问题应该很容易。grails - 显示flash消息
我有一个页面显示一个object
列表。如果在删除object
时出现DataIntegrityViolation
,我想显示一条消息。我在做什么是:
def delete() {
def instanceToDelete= Myobject.get(params.id)
try {
instanceToDelete.delete(flush: true)
redirect(action: "list", id: params.id)
}
catch (DataIntegrityViolationException e) {
flash.message = "some message"
//I want to refresh the div containing the flash.message here
}
}
这里是应显示提示信息:
<g:if test="${flash.message}">
<div class="alert alert-error" style="display: block">${flash.message}</div>
对不起 - 我知道这是一个愚蠢的问题,但我真的不能找到解决方案。
什么问题?看起来代码是正确的,如果DataIntegrityViolationException被捕获,你会看到“一些消息”字符串。 –
问题是我看不到它 – sara
我现在看到。你在谈论风格。有点误解(= –