开发者

Beans, Lists and JSP

I have a little question...

On my JSP page I have a List of beans. I want to extract a sublist of beans with a specific property (Ex. all Horror books). Can Apache Beanutils help me?

Thanks in advance..开发者_运维技巧.


In a JSP you have 2 options:

  1. Iterate over list yourself using JSTL <c:forEach> and test using JSTL <c:if> if the item matches the requirements and finally just display it.

  2. Do the same in plain Java code and call this in a servlet prior to forwarding the request to the JSP. Optionally you can wrap this in an EL function so that you can call it from inside a JSP.

The Commons Beanutils can't help much here. It has as far as I know no collection filter with a predicate. The Commons Collections and Google Collections however have.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜