Ordner in „main“ führt zu RES_NOT_FOUND
. Resources folder must be inside the webapp folder, not in the root main (siehe https://stackoverflow.com).
siehe auch: Resources (library) in JSF 2.0
JSF 2 internationalization example
Messages-Datei verwenden (i18n)
Read resource bundle properties in a managed bean
<f:view locale="#{facesContext.externalContext.requestLocale}"> <h:outputText value="#{msg['abcd']}" /> |
Using varName:
varName: is the String representing the in
FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ResourceBundle bundle = app.getResourceBundle(context, varName); String msg = bundle.getString("key"); |
Using baseName:
baseName: The fully qualified name of the resource bundle (
FacesContext context = FacesContext.getCurrentInstance(); Locale locale = context .getViewRoot().getLocale(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale, loader); String msg = bundle.getString("key"); |
<h:outputFormat value="#{mytext.WelcomeMessage}" > <f:param value="#{userSessionBean.first}" /> <f:param value="#{userSessionBean.last}" /> </h:outputFormat> |