commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sean liu <seanli...@gmail.com>
Subject [jexl] how to implement variable replacement in expressions
Date Fri, 04 Nov 2005 04:42:20 GMT
Hi guys:
 I want to use jexl to implement variable replacement in expressions. For
example:
expression: "Hello: ${person.name <http://person.name/>}, your age is ${
person.age}!"
public class Person {
 private String name;
 private int age;
  //setters,getters
}
 i use the following codes:
 Person person = new Person();
person.setName(sean);
person.setAge(26);

Expression e = ExpressionFactory.createExpression(expression);

JexlContext jc = JexlHelper.createContext();

jc.getVars().put("person", person);

message = (String) e.evaluate(jc);

System.out.println(message);

 It doesn't work.I dont know what's wrong with expression. I have never used
jexl before, so if anyone can give me some help, thanks a lot!

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message