Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring MVC Arabic Language
    text
    copied!<p>I am developing a spring mvc application which should support English &amp; Arabic. I've configured the application as mentioned in the spring reference documents and the switching of locale is working perfectly. However the arabic messages in the resource bundle is been shown as junk characters. The encoding is set as UTF-8 and it is working properly. Also I tried running the native2ascii tool for converting the messages_ar.properties file to unicode. </p> <p>Nothing works. Any help would be much appreciated.</p> <p>web.xml (partial)</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" standalone="no"?&gt; &lt;web-app version="2.4"...&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;classpath*:META-INF/spring/applicationContext*.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;filter&gt; &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt; &lt;init-param&gt; &lt;param-name&gt;encoding&lt;/param-name&gt; &lt;param-value&gt;UTF-8&lt;/param-value&gt; &lt;/init-param&gt; &lt;init-param&gt; &lt;param-name&gt;forceEncoding&lt;/param-name&gt; &lt;param-value&gt;true&lt;/param-value&gt; &lt;/init-param&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;!-- Handles all requests into the application --&gt; &lt;servlet&gt; &lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt; /WEB-INF/spring/mvc-config.xml &lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; </code></pre> <p></p> <p>mvc-config.xml (partial)</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; </code></pre> <p></p> <pre><code>&lt;context:component-scan base-package="net.omnsoq.classified.controller" use-default-filters="false"&gt; &lt;context:include-filter expression="org.springframework.stereotype.Controller" type="annotation" /&gt; &lt;/context:component-scan&gt; &lt;!-- Configures support for @Controllers --&gt; &lt;mvc:annotation-driven /&gt; &lt;!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory --&gt; &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /&gt; &lt;property name="prefix" value="/WEB-INF/views/" /&gt; &lt;property name="suffix" value=".jsp" /&gt; &lt;/bean&gt; &lt;bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource" p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application" p:fallbackToSystemLocale="false" /&gt; &lt;!-- store preferred language configuration in a cookie --&gt; &lt;bean class="org.springframework.web.servlet.i18n.CookieLocaleResolver" id="localeResolver" p:cookieName="locale" /&gt; &lt;mvc:interceptors&gt; &lt;bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="lang" /&gt; &lt;/mvc:interceptors&gt; </code></pre> <p></p> <p>jsp code</p> <pre><code>&lt;%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %&gt; ... &lt;%@page contentType="text/html;charset=UTF-8" %&gt; ... &lt;spring:message code="nav.label.myaccount" /&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload