JSP EL表达式支持方法调用

2012-03-17
浏览
导读:在JEE6中,JSP中的EL表达式支持带参数的方法调用了。可以像这样调用: ${foo.bar(baz)} 。 最新的实现是JUEL,大家可以下载试用一下。下面代码就是测试如何使用

在JEE6中,JSP中的EL表达式支持带参数的方法调用了。可以像这样调用:

${foo.bar(baz)} 。

最新的实现是JUEL,大家可以下载试用一下。下面代码就是测试如何使用:

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

用MyEclipse开发的Hibernate + JSP分页代码

【Eclipse插件开发】基于WTP开发自定义的JS

【Eclipse插件开发】基于WTP开发自定义的JS

【Eclipse插件开发】基于WTP开发自定义的JS

使用JSP实现简易的SQL报表