我正在使用MKyiong 的关于使用 JSF 2 和 NetBeans 7.4 创建简单国际化文件的良好指南,但是该文件被忽略并且不打印任何消息。
总结一下,我在 TestApplication/src/java 下创建了一个目录 resources 和一个包含内容的 welcome.properties 文件
welcome.jsf = Happy learning JSF 2.0
在我插入的 index.xhtml 文件中
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<h3>
<title>#{msg['welcome.jsf']}</title>
</h3>
</h:head>
...
在 TestApplication/web/WEB-INF 我创建了一个 faces-config.xml 内容
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
<resource-bundle>
<base-name>welcome</base-name>
<var>msg</var>
</resource-bundle>
</application>
</faces-config>
服务器正确启动并且日志是:
INFO: EclipseLink, version: Eclipse Persistence Services - 2.5.0.v20130507-3faac2b
INFO: file:/var/www/sample_projects/TestApplication/build/web/WEB-INF/classes/_TestApplicationPU login successful
INFO: EJB5181:Portable JNDI names for EJB BookShopResource: [java:global/TestApplication/BookShopResource, java:global/TestApplication/BookShopResource!rest.BookShopResource]
INFO: EJB5181:Portable JNDI names for EJB BookShopEJB: [java:global/TestApplication/BookShopEJB, java:global/TestApplication/BookShopEJB!ejb.BookShopEJB]
INFO: Registering the Jersey servlet application, named rest.BookShopResource, at the servlet mapping /webresources/*, with the Application class of the same name.
INFO: Mojarra 2.2.0 ( 20130502-2118 https://svn.java.net/svn/mojarra~svn/tags/2.2.0@11930) für Kontext '/TestApplication' wird initialisiert.
INFO: Monitoring jndi:/server/TestApplication/WEB-INF/faces-config.xml for modifications
INFO: Loading application [TestApplication] at [/TestApplication]
INFO: TestApplication wurde erfolgreich bereitgestellt in 1.207 Millisekunden.
NetBeans 7.4 对 .properties 文件的定位有什么变化吗?有什么我应该考虑的吗?