Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Webflows locale detected incorrectly as en_US, but evidence suggests locale is changed
    primarykey
    data
    text
    <p>I have 4 available locales in my project: ar_AE, en_GB, en_US, ur_PK. The default set up in my <code>localeResolver</code> is en_GB.</p> <p>No matter what I set my current locale to, when I enter a webflow, the EL expression <code>${pageContext.response.locale}</code> always evaluates to en_US, but the messages are looked up correctly (so, for example, if I'm currently ar_AE, the text is arabic, the text direction is rtl, but the current language in my JSP is en_US).</p> <p>My locale setup:</p> <pre><code>&lt;mvc:interceptors&gt; &lt;bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt; &lt;property name="paramName" value="lang" /&gt; &lt;/bean&gt; &lt;/mvc:interceptors&gt; &lt;bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"&gt; &lt;property name="defaultLocale" value="en_GB" /&gt; &lt;/bean&gt; </code></pre> <p>My JSP snippet:</p> <pre><code>&lt;a href="#i18n" class="dropdown-toggle" data-toggle="dropdown"&gt; &lt;span class="${pageContext.response.locale}-i18n-option i18n-option-selected"&gt; &lt;spring:message code="Native Name (${pageContext.response.locale})" /&gt; &lt;/span&gt; &lt;b class="caret"&gt;&lt;/b&gt; &lt;/a&gt; </code></pre> <p>My webflow config:</p> <pre><code>&lt;!--Maps request paths to flows in the flowRegistry--&gt; &lt;bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"&gt; &lt;property name="order" value="0" /&gt; &lt;property name="flowRegistry" ref="flowRegistry" /&gt; &lt;/bean&gt; &lt;!-- Dispatches requests mapped to flows to FlowHandler implementations --&gt; &lt;bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"&gt; &lt;property name="flowExecutor" ref="flowExecutor" /&gt; &lt;/bean&gt; &lt;!-- Executes flows: the entry point into the Spring Web Flow system --&gt; &lt;webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry" /&gt; &lt;!-- The registry of executable flow definitions --&gt; &lt;webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/webflows"&gt; &lt;webflow:flow-location-pattern value="/**/flow.xml" /&gt; &lt;/webflow:flow-registry&gt; &lt;!-- Plugs in a custom creator for Web Flow views --&gt; &lt;webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator" development="true" /&gt; &lt;bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator"&gt; &lt;property name="viewResolvers" ref="viewResolver" /&gt; &lt;/bean&gt; </code></pre> <p>So how do I get the correct current locale to display in my JSP within the webflow?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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