Tag Archives | spring 3

Collections in SpEL

You can reference a single member of a collection in SpEL, just like in Java. But SpEL also has the power to select members of a collection based on the values of their properties. It can also extract properties out of the collection members into a new collection. Accessing Collection Members The most basic thing [...]

Continue Reading ... Comments { 0 }

Expression Evaluation using Spring’s Expression Interface

ExpressionParser parses expression strings into compiled expressions that can be evaluated. It also supports parsing templates as well as standard expression strings. Following code demonstrates few examples of “ExpressionParser” interface. You can download the source code of this example here.

Continue Reading ... Comments { 0 }

Arithmethic Operations using Spring Expression Language

SpEL supports all of the basic arithmetic operators that Java supports, plus the carat (^) operator for performing a power of operation. Following example demonstrates arithmetic operations using Spring Expression Language. First create a new Java Project and configure it as Maven Project. For Reference, Click Here Add the following dependencies in pom.xml 1. POJO [...]

Continue Reading ... Comments { 0 }

Operators in Spring Expression Language

SpEL offers several operations that you can apply on values in a SpEL expression. Table 1.1 SpEL Operators Operation type Operators Arithmetic +, -, *, /, %, ^ Relational , ==, =, lt, gt, eq, le, ge Logical and, or, not, | Conditional ?: (ternary), ?: (Elvis) Regular expression matches Arithmetic Operators SpEL supports all [...]

Continue Reading ... Comments { 0 }

Invoke method using Spring Expression Language

You can also invoke a method using Spring Expression Language. Following example demonstrates how to invoke method using Spring Expression Language. First create a new Java Project and configure it as Maven Project. For Reference, Click Here Add the following dependencies in pom.xml 1. POJO Create Instrument Class as following 2. Configuration Create Spring-Bean.xml and [...]

Continue Reading ... Comments { 0 }

Injecting values using Annotation (SpEL)

When using annotation-style value injection, we just need to substitute the value annotations with the SpEL expressions. Following example demonstrates injecting values with Annotation based configuration using Spring Expression Language. First create a new Java Project and configure it as Maven Project. For Reference, Click Here Add the following dependencies in pom.xml 1. POJO Create [...]

Continue Reading ... Comments { 0 }

Injecting values using XML (SpEL)

We can define the bean in the XML configuration and use SpEL to inject the bean’s properties into the dependent bean. Following example demonstrates injecting values with XML based configuration using Spring Expression Language. First create a new Java Project and configure it as Maven Project. For Reference, Click Here Add the following dependencies in [...]

Continue Reading ... Comments { 0 }

Injecting Values using Spring Expression Lanugage

Spring Expression Language (SpEL) enables you to evaluate an expression dynamically and then use it in Spring’s ApplicationContext. For example, you could use SpEL to wire one bean into another bean’s property by using the bean ID as the SpEL expression: The same thing can be done without SpEL, then why it is needed? Let’s [...]

Continue Reading ... Comments { 0 }

Spring PropertyPlaceholderConfigurer using Annotation

Spring 3.1 introduces the new PropertySourcesPlaceholderConfigurer that replaces the old XML <context:property-placeholder> This replacement class is created to be more flexible and to better interact with the newly introduced Environment and PropertySource mechanism. Following example demonstrates PropertyPlaceholderConfigurer using Annotation: First create a new Java Project and configure it as Maven Project. For Reference, Click Here [...]

Continue Reading ... Comments { 0 }

Spring 3 REST Example

In this article, you will how to create a RESTful web service using the Spring framework. Spring’s annotation-based MVC framework serves as the basis for creating RESTful Web Services. First create a new Dynamic Web Project and configure it as Maven Project. For Reference, Click Here Add the following dependencies in pom.xml 1. Controller In [...]

Continue Reading ... Comments { 0 }