public class SessionIterceptor extends AbstractInterceptor {
@Autowired UserDao userDao;
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
Users u =(Users) ServletActionContext.getRequest().getSession(true).getAttribute(“loginuser”);
if(u==null){
String userName = SecurityUtils.getSubject().getPrincipal().toString();
u = userDao.findUserByName(userName);
ServletActionContext.getRequest().getSession().setAttribute(“loginuser”,u);
}
if (u == null) {
return “globleindexaction”;
} else {
return actionInvocation.invoke();
}
}
}