获取角色和用户ID并在JSF 2中保存会话

时间:2016-06-24 21:51:30

标签: session jsf jsf-2.2

要记录,请获取参数rol和id用户:

if (httpServletR.getSession().getAttribute("ush_id") != null) {
    ush_id = httpServletR.getSession().getAttribute("ush_id").toString();
    rol_id = Integer.parseInt(httpServletR.getSession().getAttribute("rol_id").toString());
    logger.info("Rol: "+rol_id);
    Rol rl=new Rol();
    rl.setRol_id(rol_id);
}

但我不知道如何在会话中保存并检索bean。现在我以这种方式回复了,但是我遇到了很多问题,因为偶尔会让变量保持在前一个会话中。

public class solicitud {
    public void listarSolicitud() throws Exception {
        adminBean adm = new adminBean();
        int usu = Integer.parseInt(adm.getUsu_id());

还是存在另一种避免这些问题的解决方案吗?

1 个答案:

答案 0 :(得分:1)

另一个Bean添加此代码:

rol_id = Integer.parseInt(httpServletR.getSession().getAttribute("rol_id").toString());

完美无缺