我的计划是开发一个具有不同语言支持的Web应用程序。检查了弹簧内部化概念并做了类似的应用程序。但问题是应用程序加载了指定为defaultLocale的语言属性文件。验证了其他StackOverflow问题和其他链接,但没有成功。
spring-hibernate.xml文件snap-shot是,
<mvc:annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources/" />
<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="basenames">
<list>
<value>classpath:global</value>
<!-- <value>classpath:global_en</value> -->
<value>classpath:db-fields</value>
<value>classpath:package</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="language" />
</bean>
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMap
ping" >
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
</list>
</property>
</bean>
Jsp文件是,
<style type="text/css">
select#languagedropdown {
margin: 0px 0px 0px 550px;
-webkit-appearance: none;
-moz-appearance: none;
text-indent: 1px;
text-overflow: '';
height:25px;
font-weight:bold;
}
</style>
<select id="languagedropdown"
name="dropdown" onchange="window.location.href=this.value;">
<option value=""> ---Language--- </option>
<option value="?language=en">English</option>
<option value="?language=fa">فارسی
/ فارسی</option>
<option value="?language=fr">Français</option>
<option value="?language=de">Deutsche</option>
<option value="?language=ar">عربى</option>
</select>
请帮助我们解决这个问题,尝试以下方法, http://javainsimpleway.com/714/ http://viralpatel.net/blogs/spring-3-mvc-internationalization-i18n-localization-tutorial-example/ http://www.journaldev.com/2610/spring-mvc-internationalization-i18n-and-localization-l10n-example https://www.mkyong.com/spring-mvc/spring-mvc-internationalization-example/