如何向Spring JSF应用程序添加资源包

如何向Spring JSF应用程序添加资源包,spring,jsf,spring-mvc,internationalization,Spring,Jsf,Spring Mvc,Internationalization,我有一个spring jsf集成应用程序。当我尝试从faces-config.xml上的资源包中获取消息时,它会毫无问题地运行。但我想将此资源包移动到spring applicationContext.xml,但问题是,它找不到我的资源包。这是我的脸 <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

我有一个spring jsf集成应用程序。当我尝试从faces-config.xml上的资源包中获取消息时,它会毫无问题地运行。但我想将此资源包移动到spring applicationContext.xml,但问题是,它找不到我的资源包。这是我的脸

    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">
    <application>
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>

         <resource-bundle>
                  <base-name>/resources/locale/messages</base-name>
                   <var>msg</var>
         </resource-bundle>
         <locale-config>
                   <default-locale>es</default-locale>
                   <supported-locale>en</supported-locale>
                   <supported-locale>fr</supported-locale>
          </locale-config>

    </application>
</faces-config>    

org.springframework.web.jsf.el.SpringBeanFacesELResolver
/资源/区域设置/消息
味精
锿
EN
fr
和我的applicationContext.xml

        <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
        <property name="defaultLocale" value="es" />
    </bean>


<bean id="msg"
      class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:messages" />
    <property name="useCodeAsDefaultMessage" value="true" />
    <property name="defaultEncoding" value="UTF-8"/>
    <property name="cacheSeconds" value="1" />
</bean>

看起来
元素不正确

<resource-bundle>
  <base-name>Messages</base-name>
  <var>msgs</var>
</resource-bundle>
<locale-config>
  <default-locale>en_US</default-locale>
  <supported-locale>nl</supported-locale>
  <supported-locale>es</supported-locale>
</locale-config>
链接教程中列出了有关如何执行此操作的详细说明

实现您自己的资源包的附加好处是,您可以将其声明为具有应用程序范围的Springbean,并通过DI将其推送到整个应用程序的其他代码中,以防您需要访问代码中的各种资源包属性

<application>
    <locale-config>
        <default-locale>en_US</default-locale>
        <supported-locale>nl</supported-locale>
        <supported-locale>es</supported-locale>
    </locale-config>
    <resource-bundle>
        <base-name>com.example.faces.i18n.Text</base-name>
        <var>text</var>
    </resource-bundle>
</application>
public class Text extends ResourceBundle {