3
我收到以下錯誤給予只能訪問用戶與權限USER_ROLE
Class
org.springframework.expression.spel.SpelEvaluationException
Message
EL1008E:(pos 0): Field or property 'ADMIN_ROLE' cannot be found on object of type 'org.springframework.security.web.access.expression.WebSecurityExpressionRoot'
我試圖訪問視圖My.GSP,我登錄的USER_ROLE
-
import org.springframework.dao.DataIntegrityViolationException
import grails.plugin.springsecurity.annotation.Secured
class MyController {
static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
@Secured(['ADMIN_ROLE','USER_ROLE'])
def index() {
redirect(action: "list", params: params)
}
@Secured(['USER_ROLE'])
def list(Integer max) {
params.max = Math.min(max ?: 10, 100)
[patientInstanceList: Patient.list(params), patientInstanceTotal: Patient.count()]
}
@Secured(['USER_ROLE'])
def create() {
[patientInstance: new Patient(params)]
}
@Secured(['USER_ROLE'])
def save() {
def patientInstance = new Patient(params)
if (!patientInstance.save(flush: true)) {
render(view: "create", model: [patientInstance: patientInstance])
return
}
flash.message = message(code: 'default.created.message', args: [message(code: 'patient.label', default: 'Patient'), patientInstance.id])
redirect(action: "show", id: patientInstance.id)
}
DB
您是否100%確定ADMIN_ROLE已正確創建? –
我編輯了我的帖子。我包含了我的數據庫的屏幕截圖 – Illep