2012-09-27 9 views
0

我創建了一個DWR ajaxfilter,但不確定如何使用Spring進行配置。 DWR版本是2.0.1,我希望配置它作爲全局過濾器,所以當session過期時,我可以在客戶端捕獲這個異常。如何在DWR中設置ajaxFilter?

package com.gbtags;

import org.directwebremoting.AjaxFilter; import org.directwebremoting.AjaxFilterChain; import org.directwebremoting.WebContextFactory; import org.directwebremoting.extend.LoginRequiredException;

import java.lang.reflect.Method;

公共類DWRSessionFilter實現AjaxFilter { 公共對象的doFilter(對象OBJ的方法,方法,對象[]參數,可以AjaxFilterChain鏈)拋出異常{

//Check if session has timedout/invalidated 
    if(WebContextFactory.get().getSession(false) == null) { 
     System.out.println("session expired"); 
     //Throw an exception 
     throw new LoginRequiredException("This operation requires login."); 

    }   

    return chain.doFilter(obj, method, params); 
} 

}

+0

如何在dwr.xml中配置它? – terry

回答

-1

添加到過濾器的dwr.xml如下所示:

+0

其中是過濾器:| –