[英]Get role and user id and save in session in JSF 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());
还是存在另一种避免这些问题的解决方案?
另一个Bean添加以下代码:
rol_id = Integer.parseInt(httpServletR.getSession().getAttribute("rol_id").toString());
完美运作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.