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

958 questions
154
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
  • 12,423
  • 14
  • 84
  • 114
70
votes
8 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,485
  • 1
  • 15
  • 20
59
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
  • 4,017
  • 9
  • 46
  • 60
56
votes
12 answers

Thymeleaf using path variables to th:href

Here's my code, where I'm iterating through:
user962206
  • 15,637
  • 61
  • 177
  • 270
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
  • 398,947
  • 96
  • 818
  • 769
49
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
  • 31,137
  • 42
  • 147
  • 238
46
votes
5 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 seem 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,678
  • 3
  • 20
  • 32
43
votes
6 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
  • 8,330
  • 10
  • 47
  • 66
43
votes
6 answers

Concatenate multiple node values in xpath

I have a XML that looks like this Hello World Hello2
krishna2642
  • 579
  • 1
  • 4
  • 10
33
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)?
Harold L. Brown
  • 8,423
  • 11
  • 57
  • 109
31
votes
8 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
  • 395
  • 1
  • 4
  • 11
29
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
  • 11,654
  • 6
  • 52
  • 81
26
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
  • 3,371
  • 3
  • 23
  • 32
26
votes
3 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,703
  • 3
  • 30
  • 50
19
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
  • 18,821
  • 13
  • 71
  • 101
1
2 3
63 64