List of usage examples for org.springframework.web.servlet DispatcherServlet LOCALE_RESOLVER_ATTRIBUTE
String LOCALE_RESOLVER_ATTRIBUTE
To view the source code for org.springframework.web.servlet DispatcherServlet LOCALE_RESOLVER_ATTRIBUTE.
Click Source Link
From source file:org.jahia.bundles.extender.jahiamodules.JspServletWrapper.java
@Override public void service(final ServletRequest req, final ServletResponse res) throws ServletException, IOException { String jspPath = getJspFilePath(req); if (jspPath != null) { req.setAttribute(Constants.JSP_FILE, jspPath); }// w ww . ja v a2 s . c om Object currentLocaleResolver = req.getAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE); req.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new LocaleResolver() { @Override public Locale resolveLocale(HttpServletRequest request) { HttpSession session = request.getSession(); if (session != null) { Locale currentLocale = (Locale) session.getAttribute(org.jahia.api.Constants.SESSION_LOCALE); if (currentLocale != null) { return currentLocale; } } return request.getLocale(); } @Override public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) { } }); // Prepare attributes for subsequent includes String p = (String) req.getAttribute("javax.servlet.include.servlet_path") + (String) req.getAttribute("javax.servlet.include.path_info"); req.setAttribute("javax.servlet.include.path_info", null); req.setAttribute("javax.servlet.include.servlet_path", p); try { ContextClassLoaderUtils.doWithClassLoader(urlClassLoader, new Callable<Void>() { public Void call() throws Exception { jspServlet.service(req, res); return null; } }); } catch (Exception e) { throw new ServletException("Error during servlet servicing", e); } req.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, currentLocaleResolver); }