commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dion Gillard <dion.gill...@gmail.com>
Subject Re: [jexl] how to implement variable replacement in expressions
Date Fri, 04 Nov 2005 10:07:07 GMT
On 11/3/05, sean liu <seanliugm@gmail.com> wrote:
> 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 ${

Try with the following Expression in double quotes:
'Hello ' + person.name + ' <http:// ' + person.name + '/>, your age is
' + person.age


> 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!
>
>


--
http://www.multitask.com.au/people/dion/
"You are going to let the fear of poverty govern your life and your
reward will be that you will eat, but you will not live." - George
Bernard Shaw

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message