struts2에서 로그인 필터에서 request 실례와 전참 얻기

1699 단어 struts2
public String intercept(ActionInvocation invocation) throws Exception {
		ActionContext ctx = invocation.getInvocationContext();     
		HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST);
		
		
		System.out.println(request.getParameter("url"));
		System.out.println(request.getRequestURI());
		System.out.println(request.getServletPath()); 
		
		
		
		
		String invocationAction=invocation.getAction().getClass().getName();		
		String invocationName=invocationAction.substring(invocationAction.lastIndexOf(".")+1,invocationAction.length());
		if(invocationName.toLowerCase().endsWith("scope"))
		{		
			if(invocation.getInvocationContext().getSession().get("user")==null)
				return BaseAction.USER;
		}
		if(invocationName.toLowerCase().endsWith("stage"))
		{
			if(invocation.getInvocationContext().getSession().get("operator")==null)
				return Action.LOGIN;
		}
		return invocation.invoke();
	}

전참하여 통과하다
publicStringintercept(ActionInvocationinvocation)throwsException
  • {
  • ActionContextctx=invocation.getInvocationContext();
  • Stringuser=(String)ctx.getSession().get("username");
  • System.out.print(user);
  • if(user!=null)
  • {
  • returninvocation.invoke();
  • }
  • System.out.print(user);
  • ctx.put ("tip", "아직 로그인하지 않았습니다. 시스템에 로그인하십시오"
  • returnAction.LOGIN;

  • .페이지에서 확인할 수 있습니다

    좋은 웹페이지 즐겨찾기