0
我有一個使用Spring-security的ZK程序。 我有三種語言的網絡程序。當用戶登錄時,我想從數據庫中檢索他的語言,並以該用戶的語言在網站中設置網站。我發現了一個解決方案與把這個在doAfterCompose(Component comp)
控制器我的網頁:如何在登錄後以用戶的語言獲得zk頁面
Locale currentLocale = (Locale) Executions.getCurrent().getSession().getAttribute(Attributes.PREFERRED_LOCALE);
Locale userLocale = user.getLocale();
if (currentLocale == null || !currentLocale.equals(userLocale)) {
Executions.getCurrent().getSession().setAttribute(Attributes.PREFERRED_LOCALE, user.getLocale());
Executions.sendRedirect(null);
}
但我不認爲這是因爲當用戶登錄時,頁面刷新兩次很好的解決方案。首先用英文顯示,然後用用戶的語言重新加載。這個beheaviour是正常的,因爲我把它放在我的代碼中,但我想要一個更好的解決方案來檢索登錄用戶的語言頁面。