English 中文(简体)
JSF 2.0 EL手动无效符用于资源键
原标题:JSF 2.0 EL handeling nulls for resource keys

问你们一个简单的问题

我有一个资源钥匙 存储在一个管理好的豆子的字符串中 我想让它在特定的地图资源捆绑中 找到它的价值

以下是我一开始所讲的:

<h:outputText value="#{msgs[bean.someVal]}"/>

我立即注意到,当某个Val是空的时,我会得到以下例外:

javax.el.PropertyNotFoundException: /webpage.xhtml at line 118 and column 188 value="#{msgs[bean.someVal]}": Property    not found on type java.util.PropertyResourceBundle

于是我试图设置一个像这样的终身制:

<h:outputText value="#{bean.someVal == null ?    : msgs[bean.someVal]}"/>

但我也有同样的错误 仅仅引用了新的价值

我在Tomcat6上运行JSF2.0(阿帕切)

有谁知道吗?

如果需要更多信息,请告诉我,我希望这足以继续下去。我认为这只是我正在做的蠢事;)

最佳回答

财产未找到

您在那里看到一个空字符串。空字符串与 null 不一样。

使用 < code> noty check 代替 < code > > check。 如果它不是一个空字符串, 它会检查值是否不是 < code> null < /code> < strong > 和

<h:outputText value="#{empty bean.someVal ?    : msgs[bean.someVal]}" />

顺便说一句,另一种办法是在 recodeBundleBundle 上提供自定义的 resourceBundleBundle 执行程序,该执行程序不会丢弃例外,而是返回 null string on handleGetObject () 方法上的空 < handleGetObject () () 方法。

问题回答

暂无回答




相关问题
MySQL like query runs extremly slow for 5000 records table

I have this issue on our production server. The application stack is, Java Web App on Tomcat 6.0.18 iBatis data access layer MySQL 5.0 database CentOS The system is deployed on virtual server having ...

Set the path of web app in META-INF/context.xml?

I m tryin to change the path of a deployed war file in Tomcat. Reading the documentation I can t figure out if this is possible without moving the context-file to the /conf directory. Is it possible ...

MySQL Connector/J Problem

So I ve been having issues with the MySQL Connector/J driver not correctly loading in a Java Web Start application that is running on Tomcat 6.0.20. I ve copied the MySQL connector JAR file into the ...

Can t connect to MySQL database from tomcat

Hey, I m getting this error: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. I m just ...

JNDI Names -- Is Prefix "jdbc/" needed?

What s up with JNDI names? I m trying to get a javax.sql.DataSource using the new annotations feature of Java 5. It s not working for me, so I want to ask... I have a in my web.xml, inside of it is ...

热门标签