這是有春季安全上顯示一個Spring Security類的屬性中的Grails
package rms
import java.util.Date;
import java.util.Set;
import enums.EmployeeStatus;
class User {
transient springSecurityService
String username
String password
boolean enabled
boolean accountExpired
boolean accountLocked
boolean passwordExpired
String firstName
String lastName
String middleName
String contactNumber
String position
String emailAddress
String employeeID
Date dateOfBirth
EmployeeStatus employeeStatus
int age
byte [] picture
static hasMany = [employeeReport: EmployeeReport]
static constraints = {
picture maxSize:20* 1024 * 1024
dateOfBirth nullable: true
employeeStatus blank: false
position blank: false
contactNumber blank: false
emailAddress blank: false, matches: "([a-z0-9_.-]+)@([da-z.-]+).([a-z.]{2,6})", email: true
age min: 18
username blank: false, unique: true
password blank: false, password: true
}
static mapping = { password column: '`password`' }
Set<SecRole> getAuthorities() {
SecUserSecRole.findAllBySecUser(this).collect { it.secRole } as Set
}
def beforeInsert() {
encodePassword()
}
def beforeUpdate() {
if (isDirty('password')) {
encodePassword()
}
}
protected void encodePassword() {
password = springSecurityService.encodePassword(password)
}
String toString(){
return "SecUser $username"
}
}
我想這個標籤<sec:loggedInUserInfo field="username"/>
我的用戶類,它工作正常,但是這並不工作<sec:loggedInUserInfo field="firstName"/>
。它給出了一個
沒有這樣的屬性:名字類:org.codehaus.groovy.grails.plugins.springsecurity.GrailsUser
是否有任何其他的方式來顯示當前登錄的其他屬性在用戶?
''用於由spring安全性定義的字段,如用戶名,啓用等,不用於開發人員定義的其他字段。 –
user1791574