英文:
Spring Framework: Is there a list of "reserved words" or "Predefined Variables" about SpEL?
问题
对于Spring Framework
中关于SpEL
的保留字或预定义变量的完整列表以及它们的相应解释在哪里?例如:
environment
systemProperties
systemEnvironment
例如,在这个有价值的教程中,只显示了上述列表中的最后两个:
请考虑如果Spring 6添加了更多的预定义变量,这将是一个改进,因此可能会有更多。
是的,我已经进行了研究 - 目前版本6 - 在官方文档中:
但其中不包含保留字。
注意:
是的,getSystemEnvironment()
和 getSystemProperties()
方法出现在AbstractEnvironment类中,但请参阅以下类:
- StandardEnvironment -
AbstractEnvironment
的子类
请查看“字段摘要”部分,其中包含systemEnvironment
和systemProperties
变量,这些变量由SpEL使用。我假设其他类可能会有environment
变量。
英文:
For Spring Framework
where is the complete list of reserved words or Predefined Variables about SpEL
with their respective explanation? It such as for:
environment
systemProperties
systemEnvironment
For example in this valuable tutorial is just shown the 2 latest of the list shown above
Consider if Spring 6 added more of them, it as an improvement, therefore could be more.
Yes, I did do a research - currently for version 6 - at the official documentation at:
But does not contain the reserved words.
Note:
Yes, appears the getSystemEnvironment()
and getSystemProperties()
methods at the AbstractEnvironment class, but see the following class:
- StandardEnvironment - subclass of
AbstractEnvironment
See the Field Summary
section, it has the systemEnvironment
and systemProperties
variables used by SpEL. I am assuming other class would have the enviroment
variable
答案1
得分: 1
以下是已翻译的内容:
在SpEL中,实际上没有像您所寻找的保留词列表,至少在通用的SpEL解析和评估中没有。
默认情况下,Spring框架在应用程序上下文和@Value
注解中提供了SpEL支持,如参考指南中所述:Bean定义中的表达式。
这是通过SpEL的StandardEvaluationContext
提供的,它使用beanFactory
作为根对象。或者更确切地说,它使用bean工厂的BeanExpressionContext
视图,同时为该评估上下文添加了一个专用的PropertyAccessor
,以便在评估期间将bean工厂中的每个beanName
视为根对象的属性。
因此,如果在工厂中注册了名为foo
的bean,@Value("#{ foo }")
将被解释为“根对象的属性foo
”,它解析为上述的bean。
因此,systemProperties
、systemEnvironment
和environment
实际上并不是预定义的SpEL
变量,而是AbstractApplicationContext
中的标准bean。
英文:
There isn't really a list of reserved words for SpEL like what you are looking for, at least not in generic SpEL parsing and evaluation.
There is default SpEL support in the application context and notably in @Value
annotations, as documented in the reference guide: Expressions in Bean Definitions.
Thi is provided via a SpEL StandardEvaluationContext
which uses the beanFactory
as the root object. Or rather, it uses a BeanExpressionContext
view of the bean factory plus a dedicated PropertyAccessor
is added to this evaluation context so that every beanName
in the bean factory is considered a property of that root object during evaluation.
As a result, if a bean named foo
is registered in the factory, @Value("#{ foo }")
will be interpreted as "the property foo
of the root object", which resolves to the aforementioned bean.
So systemProperties
/systemEnvironment
and environment
are not really predefined SpEL
variables, but rather standard beans in an AbstractApplicationContext
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论