Class StandardBeanExpressionResolver
java.lang.Object
org.springframework.context.expression.StandardBeanExpressionResolver
- All Implemented Interfaces:
BeanExpressionResolver
Standard implementation of the
BeanExpressionResolver
interface, parsing and evaluating Spring EL using Spring's expression module.
All beans in the containing BeanFactory are made available as
predefined variables with their common bean name, including standard context
beans such as "environment", "systemProperties" and "systemEnvironment".
- Since:
- 3.0
- Author:
- Juergen Hoeller, Sam Brannen
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newStandardBeanExpressionResolverwith default settings.StandardBeanExpressionResolver(@Nullable ClassLoader beanClassLoader) Create a newStandardBeanExpressionResolverwith the given bean class loader, using it as the basis for expression compilation. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcustomizeEvaluationContext(StandardEvaluationContext evalContext) Template method for customizing the expression evaluation context.evaluate(@Nullable String value, BeanExpressionContext beanExpressionContext) Evaluate the given value as an expression, if applicable; return the value as-is otherwise.voidsetExpressionParser(ExpressionParser expressionParser) Specify the EL parser to use for expression parsing.voidsetExpressionPrefix(String expressionPrefix) Set the prefix that an expression string starts with.voidsetExpressionSuffix(String expressionSuffix) Set the suffix that an expression string ends with.
-
Field Details
-
MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAME
System property to configure the maximum length for SpEL expressions: "spring.context.expression.maxLength".Can also be configured via the
SpringPropertiesmechanism.- Since:
- 6.1.3
- See Also:
-
DEFAULT_EXPRESSION_PREFIX
-
DEFAULT_EXPRESSION_SUFFIX
-
-
Constructor Details
-
StandardBeanExpressionResolver
public StandardBeanExpressionResolver()Create a newStandardBeanExpressionResolverwith default settings.As of Spring Framework 6.1.3, the maximum SpEL expression length can be configured via the
MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAMEproperty. -
StandardBeanExpressionResolver
Create a newStandardBeanExpressionResolverwith the given bean class loader, using it as the basis for expression compilation.As of Spring Framework 6.1.3, the maximum SpEL expression length can be configured via the
MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAMEproperty.- Parameters:
beanClassLoader- the factory's bean class loader
-
-
Method Details
-
setExpressionPrefix
Set the prefix that an expression string starts with. The default is "#{".- See Also:
-
setExpressionSuffix
Set the suffix that an expression string ends with. The default is "}".- See Also:
-
setExpressionParser
Specify the EL parser to use for expression parsing.Default is a
SpelExpressionParser, compatible with standard Unified EL style expression syntax. -
evaluate
public @Nullable Object evaluate(@Nullable String value, BeanExpressionContext beanExpressionContext) throws BeansException Description copied from interface:BeanExpressionResolverEvaluate the given value as an expression, if applicable; return the value as-is otherwise.- Specified by:
evaluatein interfaceBeanExpressionResolver- Parameters:
value- the value to evaluate as an expressionbeanExpressionContext- the bean expression context to use when evaluating the expression- Returns:
- the resolved value (potentially the given value as-is)
- Throws:
BeansException- if evaluation failed
-
customizeEvaluationContext
Template method for customizing the expression evaluation context.The default implementation is empty.
-