Tired of old EL in JSP not being able to invoke methods on beans etc.
Can I use SpEL from Spring 3.0 in my JSP:s?
The Spring Expression Language (SpEL) is a powerful expression language that supports querying and manipulating an object graph at runtime. We can use it with XML or annotation-based Spring configurations.
SpEL supports a wide range of features, such as calling methods, accessing properties, and calling constructors. As an example of method invocation, we call the 'concat' method on the string literal. ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser. parseExpression("'Hello World'.
While there are several other Java expression languages available, OGNL, MVEL, and JBoss EL, to name a few, the Spring Expression Language was created to provide the Spring community with a single well supported expression language that can be used across all the products in the Spring portfolio.
The upcoming Spring Framework 3.0.1 release adds a new spring:eval JSP tag that allows you to evaluate SpEL expressions from JSP pages.
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
Future versions will add native integration with JSP 2.1 or > engines via a Unified EL adaption layer.
It would be nice, wouldn't it, but no, JSP EL is a function of the JSP compiler. The best you could do would be to write a custom taglib which evaluated contained SpEL expressions, which would be rather clunky.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With