我创建了一个SessionListener
,但它不起作用,因为我不知道如何在faces-config.xml
. 我尝试了以下方法:
会话监听器
public class SessionListener implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent arg0) {
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
String param = request.getParameter("language");
IDAdminLanguage idl = (IDAdminLanguage) JSFUtils.resolve("#{languageBean}");
if (param != null && param.length() > 0) {
idl.setLanguage(param);
} else {
idl.setLanguage("de");
}
}
@Override
public void sessionDestroyed(HttpSessionEvent arg0) { }
}
面孔配置
<listener>
<listener-class>ch.idadmin.util.SessionListener</listener-class>
</listener>