Using a Java Filter to change locale not working -
i'm trying change locale using java filter following code not work jsp page still rendered in english:
public class preferencefilter implements filter { public void dofilter(servletrequest request, servletresponse response, filterchain chain) throws ioexception, servletexception { httpservletrequest req = (httpservletrequest) request; httpservletresponse res = (httpservletresponse) response; locale locale = stringutils.parselocalestring("fr"); res.setlocale(locale); chain.dofilter(req, res); } }
i using spring mvc , using own translation system translations different locales:
<bean id="messagesource" class="com.mycompany.web.translations.databasedrivenmessagesourceimpl" scope="singleton"> <property name="cacheseconds" value="3"/> <property name="defaultencoding" value="utf-8"/> </bean>
if you're using jstl internationalize jsps, it's normal: jstl doesn't locale response, configured scoped parameter or, if no locale set, request.
use
config.set(request, config.fmt_locale, locale);
where config class javax.servlet.jsp.jstl.core.config.
.
Comments
Post a Comment