dwr 反向AJAX

在web.xml里的DWR配置中加入一个参数:

<servlet-name>dwr-invoker</servlet-name>
  <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>

<init-param>
            
<param-name>
                org.directwebremoting.extend.Remoter
            
</param-name>
            
<param-value>com.xxx.base.framework.web.MyDWRRemoter</param-value>
</init-param>

<init-param>
   <param-name>activeReverseAjaxEnabled</param-name>
   <param-value>true</param-value>
  </init-param>

org.directwebremoting.extend.ServerLoadMonitor
org.directwebremoting.impl.PollingServerLoadMonitor

<body οnlοad="dwr.engine.setActiveReverseAjax(true)">

import org.directwebremoting.Browser;
import org.directwebremoting.ScriptSessions;

public class MyDWRRemoter extends DefaultRemoter
{

    
public Replies execute( Calls calls )
    
{
        HttpSession session 
= WebContextFactory.get().getSession();
        ISessionContainer sc 
= ( ISessionContainer ) session.getAttribute( ISessionContainer.SESSION_CONTAINER_KEY );

        
//session检查
        if ( sc == null || sc.getUserInfo() == null )
        
{
            logOut();
            
return super.execute( new Calls() );
        }

        
else
        
{
            IUserInfo userInfo 
= sc.getUserInfo();
            
if(!SecurityFactory.getInstance().isOnline( userInfo.getUserID(), session.getId() ))
            
{
                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("logOut()"));
    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值