2012-06-14 105 views
2

我有一个f:loadBundle,它从我的类路径中加载一个属性文件。javax.el.PropertyNotFoundException while using f:loadBundle ...这是否正确实现了规范?

<f:loadBundle basename="com.xxx.ui.messages" var="msg" /> 

后来,我尝试从资源包使用消息的语法如下:

<h:outputText value="test message: #{msg.does_not_exist} --"/> 

它曾经是,JSF会打印出“未找到”的消息,但现在它抛出一个异常。规范是否改变或者这是正确的行为?

我使用Mojarra 2.1.9和JUEL 2.2.4作为EL解析器。这里的堆栈跟踪:

javax.el.PropertyNotFoundException: /WEB-INF/xxx.xhtml @10,70 value="test message: #{msg.does_not_exist} --": Property 'does_not_exist' not found on type java.util.PropertyResourceBundle 
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111) 
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) 
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) 
    at javax.faces.component.UIOutput.getValue(UIOutput.java:169) 
    at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205) 
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355) 
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164) 

编辑: 正确的行为都可以在这里进行验证:http://javaserverfaces.java.net/nonav/docs/2.0/vdldocs/facelets/f/loadBundle.html

(它说文字字符串??? ??? KEY从地图,其中主要是返回即使除去JUEL

+0

您之前是否使用过不同的JSF实现? “回报垃圾”总是愚蠢的行为,我怀疑这是什么指定。 – millimoose

+0

我相当肯定这是正确的行为......无论好坏。看到这里:http://stackoverflow.com/questions/6451215/jsf-how-to-remove-the-surrounding-if-message-not-found-in-messagebundle –

+0

验证,???不存在 ??应根据这里的文档返回:http://javaserverfaces.java.net/nonav/docs/2.0/vdldocs/facelets/f/loadBundle.html –

回答

3

所以答案实际上是盯着你的脸后,同样的问题...道具@millimoose为:键值为在地图抬头,而不是MissingResourceException异常被抛出)

编辑刚开我开始走下正确的道路。

通知的规范是:

文字字符串??? ??? KEY从地图返回,其中KEY是 在地图中查找的关键,而不是 MissingResourceException被引发。

但我的堆栈跟踪这样说:

javax.el。 PropertyNotFoundException:/WEB-INF/xxx.xhtml @ 10,70 值= “测试消息:#{msg.does_not_exist} - ”:属性 'does_not_exist' 不是类型java.util.PropertyResourceBundle

发现

啊哈,一个可能的错误!

知道这个类将从tomcat/lib中取出,我浏览了它们的源代码并且javadoc here。注意“getValue()”的抛出声明?

这与规范here形成鲜明对比。

因此,我从tomcat/lib中删除了el-api,并将其替换为spec jar(here)并解决问题!

为什么Tomcat与规范如此不同是超越我......那些疯狂的Apache家伙。