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()"));
}
}