Java 使用SpringMVC中的属性文件更新默认区域设置值

Java 使用SpringMVC中的属性文件更新默认区域设置值,java,spring,spring-mvc,spring-boot,Java,Spring,Spring Mvc,Spring Boot,我的计划是用messages.properties文件的值更新servlet-context.xml中的默认语言环境值。验证了其他StackOverflow问题和其他链接,但没有成功 servlet-context.xml是 <context:property-placeholder location="C:\\Users\\Mahesh\\Downloads\\SpringInternalization\\src\\main\\resources\\messages.properties

我的计划是用messages.properties文件的值更新servlet-context.xml中的默认语言环境值。验证了其他StackOverflow问题和其他链接,但没有成功

servlet-context.xml是

<context:property-placeholder location="C:\\Users\\Mahesh\\Downloads\\SpringInternalization\\src\\main\\resources\\messages.properties" />

<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />

   <mvc:resources mapping="/resources/**" location="/resources/" />

 <!-- Resolves views selected for rendering by @Controllers to .jsp resources 
    in the /WEB-INF/views directory -->
<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/" />
    <property name="suffix" value=".jsp" />
</bean>

<bean id="messageSource"
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <!-- <property name="basename" value="classpath:messages" /> -->
    <property name="basenames">
            <list>
                <value>classpath:messages</value>
            </list>
        </property>
    <property name="defaultEncoding" value="UTF-8" />
 </bean>

 <bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" >
    <value>${property.language}</value>
    </property>
</bean>

 <!-- 
 <mvc:interceptors>
    <bean
        class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
        <property name="paramName" value="lang" />
    </bean>
</mvc:interceptors>
-->
<context:component-scan base-package="com.jocata.spring" />

类路径:消息
${property.language}
请帮个忙。提前谢谢。 尝试了以下方法


您的语言文件名是什么? 为什么需要指定属性文件的绝对路径

试试这个

<context:property-placeholder location="classpath:messages.properties" />

或者在文件路径中使用正斜杠

<context:property-placeholder location="file:C:/Users/Mahesh/Downloads/SpringInternalization/src/main/resources/messages.properties" />

非常感谢@Rocherlee