在这里,我只是想对我需要的字符串键进行干燥,但唯一有效的是将字符串直接放入分配中:request['RequestStopwatch.start'] = System.currentTimeMillis()
.
任何指针?
class RequestStopwatchFilters {
def REQ_KEY = 'RequestStopwatch.start'
def filters = {
all(controller:'*', action:'*') {
before = {
log.debug(""+System.currentTimeMillis() + " " + request)
// NULL pointer exception on REQ_KEY here:
request[REQ_KEY] = System.currentTimeMillis()
}
after = { Map model ->
if (log.isDebugEnabled()) {
// NULL pointer exception on REQ_KEY here:
log.debug("Stopped request before view at " + (System.currentTimeMillis() - request[REQ_KEY]) + "ms")
}
}
afterView = { Exception e ->
if (log.isDebugEnabled()) {
// NULL pointer exception on REQ_KEY here:
log.debug("Stopped request at " + (System.currentTimeMillis() - request[REQ_KEY]) + "ms")
}
}
}
}
}