JSP El Expressions support method calls

Source: Internet
Author: User
Tags expression

In JEE6, the El expression in the JSP supports method calls with parameters. You can call it like this:

${foo.bar (Baz)}.

The latest implementation is Juel, you can download a trial. The following code is the test of how to use:

// the ExpressionFactory implementation is  de.odysseus.el.ExpressionFactoryImpl|
System.setProperty("javax.el.methodInvocations", "true");
ExpressionFactory factory = new de.odysseus.el.ExpressionFactoryImpl (System.getProperties());

// package de.odysseus.el.util provides a ready-to-use subclass of ELContext
de.odysseus.el.util.SimpleContext context = new de.odysseus.el.util.SimpleContext ();
07.
// set value for top-level property "foo" to String value "bar"
factory.createValueExpression(context, "${foo}", String.class).setValue(context,  "bar");

// create an expression
ValueExpression e = factory.createValueExpression(context, "${foo.toUpperCase()}",  String.class);
// evaluate
System.out.println(e.getValue(context)); // --> BAR

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.