问题
I'm using spring-EL with spring security
Is it possible to make 'complex' conditional expressions with parentesis?
@PreAuthorize("( hasRole('ROLE_USER') and ( isOwnerDocumentUUID( #docUuids ) ) or hasRole('ROLE_ADMIN') ")
throw an java.lang.IllegalArgumentException:
Failed to parse expression
but
@PreAuthorize("hasRole('ROLE_USER') and ( isOwnerDocumentUUID( #docUuids ) ")
is accepted.
回答1:
You have one extra (
, the following should work:
@PreAuthorize("( hasRole('ROLE_USER') and isOwnerDocumentUUID( #docUuids ) ) or hasRole('ROLE_ADMIN') ")
来源:https://stackoverflow.com/questions/5350502/use-complex-expression-with-spring-el-conditional-parenthesis