以“is"开头的布尔属性不工作 [英] boolean properties starting with "is" does not work
问题描述
我有一个使用 JSF 2.1 和 PrimeFaces 的项目.我尝试使用一个简单的 <h:outputText>
引用 #{myBean.matriz}
并收到此错误:
I have a project that use JSF 2.1 and PrimeFaces. I tried to use a simple <h:outputText>
referencing #{myBean.matriz}
and I got this error:
SEVERE: javax.el.PropertyNotFoundException: ... value="#{myBean.matriz}": Missing Resource in EL implementation: ???propertyNotReadable???
getter 是:isMatriz()
.应该是 getMatriz()
吗?
The getter is: isMatriz()
. Should it be getMatriz()
?
推荐答案
is
前缀仅适用于 boolean
,不适用于 Boolean
.
The is
prefix works only for boolean
, not Boolean
.
您显然实际上有一个 Boolean
属性.
You've there apparently actually a Boolean
property.
您有 2 个选项来修复它:
You've 2 options to fix it:
- 使用
get
前缀重命名 getter. - 将
Boolean
替换为boolean
.请注意,它将默认为false
而不是null
.
- Rename the getter with
get
prefix. - Replace
Boolean
byboolean
. Note that it will default tofalse
instead ofnull
.
另见:
- JavaBeans 规范 - 第 8.3.2 章
- Java 如何表达式语言解析布尔属性?(在 JSF 1.2 中)
- JavaBeans specification - chapter 8.3.2
- How does Java expression language resolve boolean attributes? (in JSF 1.2)
See also:
与具体问题无关,类路径对于 EL 实现来说似乎是一团糟.消息 Missing Resource in EL implementation: ???propertyNotReadable???
表明 EL impl 无法在自己的 JAR 中找到相关的错误消息,应该如下所示
Unrelated to the concrete problem, the classpath seems to be a mess as to EL implementation. The message Missing Resource in EL implementation: ???propertyNotReadable???
indicates that the EL impl wasn't able to find the associated error message in own JAR which should look like this
Property 'matriz' not found on type com.example.MyBean
确保您没有在 /WEB-INF/lib
中任意下载 EL JAR 文件.摆脱他们.servletcontainer 已经提供了自己的.
Make sure that you don't have arbitrarily downloaded EL JAR files in /WEB-INF/lib
. Get rid of them. The servletcontainer already provides its own.
这篇关于以“is"开头的布尔属性不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!