mahi mahi - 3 years ago 101
Java Question

Update the default locale value by using properties file in Spring MVC

My plan is to update the default locale value in servlet-context.xml with the value of file. Verified the other StackOverflow questions and other links as well, but not the success.

servlet-context.xml is,

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

<!-- 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 -->
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />

<bean id="messageSource"
<!-- <property name="basename" value="classpath:messages" /> -->
<property name="basenames">
<property name="defaultEncoding" value="UTF-8" />

<bean id="localeResolver"
<property name="defaultLocale" >

<property name="paramName" value="lang" />
<context:component-scan base-package="com.jocata.spring" />

Please help on this guys. Thanks in advance.
Tried the following,

Use property file's property in spring mvc configuration servlet xml

Answer Source

What are your language file names? Why do you need to specify the absolute path of your properties file?

Try this

<context:property-placeholder location="" />

OR use forward slash in your file path

<context:property-placeholder location="file:C:/Users/Mahesh/Downloads/SpringInternalization/src/main/resources/" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download