DWR拦截器

来源:互联网 发布:为什么叫矩阵革命 编辑:程序博客网 时间:2024/06/11 15:57

 web.xml

 

<servlet>
        <servlet-name>dwr</servlet-name>
        <!-- org.directwebremoting.spring.DwrSpringServlet -->
        <servlet-class>           
            org.directwebremoting.servlet.DwrServlet
        </servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
            <!--开发时设为true,生产时设为false-->
        </init-param>
        <init-param>
            <param-name>
                org.directwebremoting.extend.Remoter
            </param-name>
            <param-value>filters.AuthorityDWRRemoter</param-value>
        </init-param>
        <init-param>
            <param-name>activeReverseAjaxEnabled</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>crossDomainSessionSecurity</param-name>

            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>exposeInternals</param-name>
            <param-value>true</param-value>
        </init-param>   
        <init-param> 
            <param-name>scriptCompressed</param-name> 
            <param-value>true</param-value> 
        </init-param>

       <load-on-startup>1</load-on-startup>
    </servlet>

 

处理类:

 

public class AuthorityDWRRemoter extends DefaultRemoter{

        public Replies execute( Calls calls )
        {
            HttpSession session = WebContextFactory.get().getSession();
            GlobalInput mGlobalInput=(GlobalInput) session.getAttribute("GI");

            //session检查
            if(mGlobalInput==null){
                    logOut();
                    return super.execute( new Calls() );
            }
            return super.execute( calls );
        }

        private void logOut()
        {
            WebContext wct = WebContextFactory.get();
            Util utilThis = new Util(wct.getScriptSession());
            utilThis.addScript( new ScriptBuffer("_DWRLogout()"));
        }
    }

 

 

原创粉丝点击