需要依赖
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
</dependencies>
代码
public static void main(String[] args) {
EvaluationContext context = new StandardEvaluationContext();
User user = new User(99, "Dubby", "123456");
context.setVariable("user", user);
ExpressionParser parser = new SpelExpressionParser();
String sourceStr = "'User:ID:'.concat(#user.id)";
String destStr = parser.parseExpression(sourceStr).getValue(context, String.class);
System.out.println(destStr);
}