我为当前用户收集字符串的代码如下所示。
package timetracker2
import grails.timesecurity.*
import timetracker2.TimeController
class Time {
def springSecurityService
int id
Project projectname
Date dateCreated
Date dateWorked
Double timeSpent
TimeClassification classification
String currentUser = {
String currentUser = springSecurityService.getCurrentUser()
def user = springSecurityService.getCurrentUser()
String username = user
return username
}
static constraints = {
timeSpent blank: false
classification blank: true
}
static mapping = {
table 'Time'
cache true
id column: 'Time_id'
dateCreated column: 'Date_created'
dateWorked column: 'Date_Worked'
timeSpent column: 'Time_Spent'
currentUser column: 'Username'
}
}
这是我得到的字符串.... timetracker2.Time$_closure1@108115
那是怎么回事????任何帮助将不胜感激。
我也尝试过使用获取授权,并且尝试在我的 person 类中添加一个 toString 方法。可惜没有成功。