Strutsブロッキングの使用






	
   	
   	
   	
   	
   	
	
   
    
   
    
    	
    		
    		
    			
    			
    		
    	
    	
    	
    	
    	
    		/WEB-INF/jsp/inc/error.jsp
    		/WEB-INF/jsp/login.jsp
    		/WEB-INF/jsp/inc/exception.jsp
    	
    	
    	
    		
    	
    	
    	
    		${url}
    	
		
		
		
		
			/WEB-INF/jsp/{1}/{2}.jsp
			/WEB-INF/jsp/{1}/{2}Input.jsp
			${url}
			
		
    

	

次に、ブロッキングのコードを示します.
package org.test.ssh.filter;

import org.springframework.stereotype.Component;
import org.test.ssh.model.User;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
/**
 *  struts        ,       ,   filter      。
 * @author asus_n56
 *
 */
@SuppressWarnings("serial")
@Component("authInterceptor")
public class AuthInterceptor extends AbstractInterceptor {

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		String an = invocation.getProxy().getActionName();//  Action   
		if (!an.startsWith("login")) {
			User loginUser = (User)ActionContext.getContext().getSession().get("loginUser");
			if (loginUser==null) {
				return "login";
			}
		}
		return invocation.invoke();
	}

	
}