List of Spring EL variables?

Spring EL supports some predefined variables

  • {#systemProperties. ... }
  • {#systemEnvironment. ... }
  • {#request. ...}
  • {#session. ...}

The first two times are documented in Spring Link: Chapter 6. Spring Expression Language (SpEL) . These two others are not mentioned in the Spring reference (or I did not find them). (I found them in this slides , as well as its use in Spring social and this question ).

So my question is: is there a more or less complete list of predefined spring -el variables?

I assume that some of these predefined variables are not defined by the Spring kernel itself, but by "activating" some modules, such as spring-mvc. Therefore, I am interested in the variables available in the more or less common Spring + jpa + mvc + application .

+7
source share
2 answers

I cannot answer your root question, but I can give you a hint.

There is a specific predefined beans registered when you launch your application context, but which depends on the type of context you are using.

Usually, systemProperties and systemEnvironment . By loading Spring into a web application, you will also get servletContext , contextParameters and contextAttributes . I believe request and session also related to the context of the web application.

I discovered this while debugging my application that uses Spring 3.0.6RELEASE. A good starting point is the SpringBeanELResolver.getValue () method.

+5
source

I also notice that environment allows the current instance of org.springframework.core.env.Environment . I'm not sure if this is a documented feature, but I was looking for a concise way to do the following in the @Configuration class:

 @Value("#{environment.acceptsProfiles('test')}") private boolean test; 

Which then allows me to disable this value in the future bean defintions.

I introduced the following JIRA to solve this problem:

https://jira.springsource.org/browse/SPR-9037

+7
source

All Articles