Questions tagged [spring-el]

The Spring Expression Language (SpEL for short) is a powerful expression language that supports querying and manipulating an object graph at runtime. The language syntax is similar to Unified EL but offers additional features, most notably method invocation and basic string templating functionality.

Spring Expression Language was introduced in Spring 3.0.x

The Complete reference can be found in the reference documentation.

Guides:

Video tutorial on Spring Framework

Blog:

Related tags

866 questions
135
votes
4 answers

Spring Expression Language (SpEL) with @Value: dollar vs. hash ($ vs. #)

I'm a little confused concerning when to use ${...} compared to #{...}. Spring's documentation only uses #{...}, but there are plenty of examples that use ${...}. Furthermore, when I started with SpEL I was told to use ${...} and it works fine. For…
sjngm
  • 11,411
  • 13
  • 72
  • 105
54
votes
3 answers

How do I get a property value from an ApplicationContext object? (not using an annotation)

If I have: @Autowired private ApplicationContext ctx; I can get beans and resources by using one of the the getBean methods. However, I can't figure out how to get property values. Obviously, I can create a new bean which has an @Value property…
HappyEngineer
  • 3,819
  • 8
  • 42
  • 58
53
votes
9 answers

How does Spring 3 expression language interact with property placeholders?

Spring 3 has introduced a new expression language (SpEL) which can be used in bean definitions. The syntax itself is fairly well specified. What isn't clear is how, if at all, SpEL interacts with the property placeholder syntax that was already…
skaffman
  • 381,978
  • 94
  • 789
  • 754
50
votes
7 answers

How to fill HashMap from java property file with Spring @Value

Is it possible to use Spring @Value, to map values from properties file to the HashMap. Currently I have something like this, and mapping one value is not a problem. But I need to map custom values in HashMap expirations. Is something like this…
d-sauer
  • 1,205
  • 1
  • 10
  • 17
41
votes
6 answers

Concatenate multiple node values in xpath

I have a XML that looks like this Hello World Hello2
krishna2642
  • 549
  • 1
  • 4
  • 9
38
votes
10 answers

Thymeleaf using path variables to th:href

Here's my code, where I'm iterating through:
user962206
  • 13,699
  • 56
  • 164
  • 259
35
votes
1 answer

Calling static methods from Spring Security Expressions?

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 described here, but I also found reference to directly calling static methods…
C. Ross
  • 28,735
  • 39
  • 139
  • 230
34
votes
4 answers

Spring @Value TypeMismatchException:Failed to convert value of type 'java.lang.String' to required type 'java.lang.Double'

I want to use the @Value annotation to inject a Double property such as: @Service public class MyService { @Value("${item.priceFactor}") private Double priceFactor = 0.1; // ... and using Spring property placeholder (Properties…
guilhebl
  • 6,652
  • 8
  • 40
  • 62
28
votes
1 answer

Thymeleaf: show text if the attribute and property exists

Is there a simple way in thymeleaf to show the content of an attribute property if the property and the attribute exist? If there's an attribute "error" with a property "summary" in my html page, I'd like to show it:
James
  • 10,392
  • 4
  • 46
  • 76
27
votes
3 answers

Spring Boot - How to disable @Cacheable during development?

I'm looking for 2 things: How to disable all caching during development with Spring boot "dev" profile. There doesn't seam to be a general setting to turn it all off in application.properties. What's the easiest way? How to disable caching for a…
Wouter
  • 1,370
  • 2
  • 16
  • 30
25
votes
7 answers

Thymeleaf + Spring : How to keep line break?

I'm using Thymeleaf template engine with spring and I'd like to display text stored throught a multiline textarea. In my database multiline string are store with "\n" like this : "Test1\nTest2\n...." With th:text i've got : "Test1 Test2" with no…
Daividh
  • 325
  • 1
  • 3
  • 10
24
votes
2 answers

Compare Enums in SpEL

At Spring's @Cacheable annotation I want to specify an unless condition. However my return value is neither a primitive type nor a Java bean, but an Enum. How can I compare for equality with another Enum in SpEL (Spring Expression Language)?
Bernhard
  • 5,161
  • 6
  • 35
  • 78
21
votes
1 answer

No bean resolver registered in the context to resolve access to bean

I'm trying to implement method security using Java Config, but I'm getting a error:- org.springframework.expression.spel.SpelEvaluationException: EL1057E:(pos 1): No bean resolver registered in the context to resolve access to bean…
Kaushik
  • 2,991
  • 2
  • 19
  • 31
20
votes
2 answers

How do I set JobParameters in spring batch with spring-boot

I followed the guide at http://spring.io/guides/gs/batch-processing/ but it describes a job with no configurable parameters. I'm using Maven to build my project. I'm porting an existing job that I have defined in XML and would like to pass-in the…
Philippe
  • 6,169
  • 3
  • 26
  • 46
17
votes
7 answers

Spring 3: Inject Default Bean Unless Another Bean Present

I would like to configure Spring via XML such that if a particular bean exists, it will be injected into the target bean. If it does not exist, a different, default bean, will be injected. For example if I have a file like this
SingleShot
  • 17,762
  • 13
  • 66
  • 100
1
2 3
57 58