session值取不到

来源:百度知道 编辑:UC知道 时间:2024/06/07 16:57:49
我在action中把登陆的人员对象放入session中request.getSession().setAttribute("loginPerson", p);为什么在另一个action中取不到session值。
Person p = (Person) request.getSession().getAttribute("loginPerson");
得到p的值为null,高手帮帮忙,有几种原因啊?
我测过,P的值不为空,Person person = new Person();
BeanUtils.copyProperties(person, form);
Person p = ps.login(person);
System.out.println(p.getName());

HttpSession session = request.getSession();
session.setAttribute("loginPerson", p);
ActionForward forward = null;
if (p != null) {
if (p.getRole().equals("0")) {

forward = new ActionForward("/operatePlan.do?option=showPlan");
}
if (p.getRole().equals("1")) {

forward = new ActionForward(
"/operateTask.do?option=showAddTask");
}
if (p.getRole().equals("2")) {

forward

可能两个地方已经不是同一个session了,可能重定向过

应该是request.getSession().setAttribute("loginPerson", p)这里的问题。
p里面没有值.....

不可能取不到 除非你的P值为空