我試圖使用Java過濾器來改變語言環境而作爲JSP頁面仍呈現在英文下面的代碼不起作用:使用Java過濾器來改變區域設置不工作
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);
}
}
我還使用Spring MVC和我們使用的是自己的翻譯系統獲得的翻譯不同語言環境:如果您正在使用JSTL國際化JSP中
<bean id="messageSource"
class="com.mycompany.web.translations.DatabaseDrivenMessageSourceImpl" scope="singleton">
<property name="cacheSeconds" value="3"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
JSP頁面是否生成正確的內容?也許它也是設置場所本身。嘗試設置*鏈接後的區域設置*。 –
你好,我已經編輯了這個問題,增加了一些關於我們如何爲不同的語言環境獲得不同翻譯的細節。我應該在第一次這樣做。 –