public String intercept(ActionInvocation invocation) throws Exception { // TODO Auto-generated method stub // 对LoginAction不做该项拦截 Object action = invocation.getAction(); if (action instanceof UserAction) { System.out.println("exit check login, because this is login action."); return invocation.invoke(); } // 确认Session中是否存在LOGIN Map session = invocation.getInvocationContext().getSession(); User user = (User) session.get("user"); if(user!=null){ // 存在的情况下进行后续操作。 System.out.println("already login!"); return invocation.invoke(); }else{ // 否则终止后续操作,返回LOGIN System.out.println("no login, forward login page!"); return Action.LOGIN; }
问一下 最后else中的 return Action.LOGIN; 这个return到哪里? 正常应该是在struts.xml中接收它么?然后通过struts.xml映射到login.jsp登录界面么?
这里有点糊涂~
是在struts.xml中 定义一个全局的 <global-results> 么?