public class AuthorityInterceptor extends AbstractInterceptor {
public AuthorityInterceptor() {
// TODO Auto-generated constructor stub
}
private Logger log = Logger.getLogger(AuthorityInterceptor.class);
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext context = invocation.getInvocationContext();
Map session = context.getSession();
TabUsers user =null;
if (session.get("managerEntity") != null) {
user = (TabUsers) session.get("managerEntity");
log.info("拦截器捕获.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + user.getNickname());
}
if (user == null) {
return new RedirectResult("/backmanager/first/edit.do").toString();
} else {
//return "/home/index";
return invocation.invoke();
}
}
}
上面的代码是Struts2 中的自定义拦截器,当我确定用户登录之后跳转到另一个action 的方法中
现在确定已经跳入到这个action的方法中,但是HttpServletRequest 对象获得为空。不知道这是
什么原因,希望高手能回答。
@Action("/backmanager/home/first/${type}/edit.do")
public String createframe() {
String realPath = getServletRequest().getRealPath("/");
contentService.setPath(realPath + "backmanager/content/content.xml");
log.info(" --" + contentService.getPath());
listContent = contentService.getList(type);
return "index";
}
上面的就是action 中跳转的方法