tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Spring > Expression Language > String Concatenation

String Concatenation 

The Spring Expression Language (SpEL) is a simple and powerful expression language which helps to query and manipulate objects at runtime. The following example shows concatenating strings using concat method of SpEL.

File Name  :  
com/bethecoder/tutorials/spring3/tests/spel/StringConcatTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.spring3.tests.spel;

import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

public class StringConcatTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    ExpressionParser parser = new SpelExpressionParser();
    Expression exp = parser.parseExpression("'BTC'.concat(' BTC')");
    String message = exp.getValue(String.class);
    System.out.println(message);

    exp = parser.parseExpression("'BTC'.concat(' BTC').concat(' BTC')");
    message = exp.getValue(String.class);
    System.out.println(message);
  }

}
   

It gives the following output,
BTC BTC
BTC BTC BTC


                    Print

   



Books Recommendation

 
 
bl  br