java jstl foreach,JSTL c:forEach不会遍历集合

Does anyone has any idea, why this code would work:

and this code would work:

But this code would NOT work (nothing appears in GUI):

I am using namespace "http://java.sun.com/jstl/core". allocations is a collection in java. I have tried everything I could think of and have no idea what to try next.

解决方案

The #{} notation is from unified EL. This is only supported in JSTL 1.2. Your JSTL namespace URI in combination with the fact that you're using JSF indicates that you're actually using JSTL 1.1.

You have 2 options:

Use ${} notation instead. You should only guarantee that the bean is already present in the scope. The ${} notation namely won't auto-create managed beans (the #{} does that).

Upgrade to JSTL 1.2. Download links and details can be found in our JSTL wiki page. Don't forget to change the XML namespace URI to http://java.sun.com/jsp/jstl/core.

Needless to say that option 2 is preferred. You should ban ${} from your JSF pages.

See also:

As a completely different alternative, you could also just use Facelets' own instead of the . You should however understand the major difference that the Facelets one runs during view render time and that the JSTL one runs during view build time. See also JSTL in JSF2 Facelets... makes sense?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值