Calling static methods from Spring Security Expressions?

后端 未结 1 1751
北恋
北恋 2020-12-16 09:46

I\'m looking for a way to extend Spring Security Expressions to support an existing security infrastructure. I\'m aware you can extend the MethodSecurityExpressionRoot as d

相关标签:
1条回答
  • 2020-12-16 10:31

    By using the T(fully.qualified.name).methodName() syntax:

    You can use the special T operator to specify an instance of java.lang.Class (the type). Static methods are invoked by using this operator as well. The StandardEvaluationContext uses a TypeLocator to find types, and the StandardTypeLocator (which can be replaced) is built with an understanding of the java.lang package. This means that T() references to types within java.lang do not need to be fully qualified, but all other type references must be.

    The T element returns a reference to the type instead of an instance. For example, the equivalent of Collections.singleton("Hello") is

    T(java.util.Collections).singleton('Hello')
    
    0 讨论(0)
提交回复
热议问题