新的起点 新的开始

快乐生活 !

JSP EL 表达式支持方法调用

    在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

posted on 2009-08-10 21:31 advincenting 阅读(2463) 评论(2)  编辑  收藏

评论

# re: JSP EL 表达式支持方法调用 2009-08-11 09:54 99读书人

不错啊啊  回复  更多评论   

# re: JSP EL 表达式支持方法调用 2009-08-13 21:12 肇哥

不错哦  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 

公告

Locations of visitors to this page

导航

<2009年8月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345

统计

常用链接

留言簿(13)

随笔分类(71)

随笔档案(179)

文章档案(13)

新闻分类

IT人的英语学习网站

JAVA站点

优秀个人博客链接

官网学习站点

生活工作站点

最新随笔

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜