संपादित एक लिंक का उपयोग बदल रहा है: मेरी स्प्रिंग ढांचा संस्करण 3.0.5वसंत MVC 3 लोकेल काम नहीं कर रहा
यहाँ एक छोटा सा मुद्दा है, भाषा, जब मैं भाषा परिवर्तक लिंक पर क्लिक करें नहीं बदल रहा है।
भाषा फाइलें (message_xx.properties) क्लासपाथ i18n निर्देशिका में हैं। फ़ाइलें हैं:
i18n/messages_en.properties
i18n/messages_ar.properties
स्प्रिंग विन्यास
<!-- Component scanner. This is used to automatically find Spring annotations like @Service and @Repository -->
<context:component-scan base-package="com.keype" />
<!-- Annotation driven programming model -->
<mvc:annotation-driven />
<context:annotation-config />
<mvc:resources mapping="/static/**" location="/static/" />
<!-- Session Object Configuration -->
<bean id="session" class="com.keype.system.Session" scope="session">
<aop:scoped-proxy />
</bean>
<!-- The View Resolver -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp"
/>
<!-- i18n Configuration. Default language is english. Change language using ?language=en -->
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<!-- Message text files. This is set UTF-8 to display Arabic UTF correctly. -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:i18n/messages" />
<property name="defaultEncoding" value="UTF-8"/>
</bean>
JSP कोड
<a href="?lang=ar"><spring:message code="header.arabic" /></a> |
<a href="?lang=en"><spring:message code="header.english" /></a>
मुद्दा है से एक वर्ग है, जब मैं भाषा बदलने के लिए ऊपर दिए गए लिंक पर क्लिक करें, स्थान बदलती कार्यक्षमता काम नहीं कर रही है। मैंने "डिफ़ॉल्ट" को "ar" में बदलकर परीक्षण किया और मुझे अरबी पाठ मिल रहा है।
संभवतः यहां क्या गलत हो सकता है? टॉमकैट लॉग में कुछ भी नहीं है।
मैंने अभी कोशिश की। लेकिन मुझे अपवाद मिल रहा है: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: अमान्य सामग्री तत्व 'ref' के साथ शुरू हुई थी। '{"Http://www.springframework.org/schema/beans":bean," http://www.springframework.org/schema/mvc":interceptor}' में से एक की उम्मीद है। वैसे, यह किसी भी ट्यूटोरियल में कहीं भी अजीब नहीं है जिसे मैंने एक इंटरसेप्टर पंजीकरण के बारे में बताया है। कोई विचार? –
और मैं यह भी कोशिश की: <सेम वर्ग = "org.springframework.web.servlet.i18n.LocaleChangeInterceptor" /> MVC: इंटरसेप्टर> कोई भाग्य –
आप ठीक कह रहे हैं, तत्व अनुमति नहीं है। ¿क्या आपने संपादित उत्तर में दिखाए गए लैंग परम को शामिल किया था? –