//アノテーション構成"true"); dynamic.setinitParameter( "Pollandcometenabled"、 "true"); dynamic.setinitParameter( "ActiveereverseajaxEnabled"、 "true"); dynamic.setinitParameter( "maxwaitafterwrite"、 "1800000"); dynamic.setinitparameter "60000"); dynamic.setinitParameter( "classes"、dwrannotationclasssconfiguration()); dynamic.addmapping( "/dwr/*");} // dwr annotation classes、configure dwrannotationclasssconfiguration(){stringbuffer config = new new new stringbuffer(); config.append( "com.g360.bean.reconsole.opcost.annualopcostrequestcontroller"); config.append( "、"); config.append( "com.g360.bean.security.sessesexparam"); return config.tostring();上面我的配置是基于注解版的DWRサーブレット(将web.xml里面的サーブレット配置转换为了纯java代码配置)、当然也包括前端和后端直接交互的类(
com.g360.bean.reconsole.opcost.annualopcostrequestcontroller、com.g360.bean.security.sessionexpiredparam
)也是使用注解配置的(dwr注解配置、包括@remoteproxy、@remotemethod)、这对于有些注解配置基础的同学来说可能比较容易看懂、对于初次接触的有什么不懂的可以给我留言哦;
com.g360.bean.security.sessionexpiredparam的注解配置如下所示:
@Component( "SessionExpiredParam") @RemoteProxy(creator = springcreator.class、scope = scriptscope.application、name = "remote"、creatorparams = @params(name = "beanname"、value = "sessexpiredparam")))パブリッククラスセッションloggerfactory.getLogger(SessionExpiredParam.class); public boolean ssessionexpire(string sessionid){return null == constantCacheService.getCacheConStant(SESSIONID); } @RemoteMethod public void setEnabledWrupDate(String SESSIONID){ScriptSession ScriptSession = webContextFactory.get()。getScriptSession(); string jsessionId = scriptsession.gethttpsessionid(); string dwrsessionid = scriptsession.getid(); logger.info(string.format( "set jsessionId = [%s]、dwrsession = [%s]プッシュイネーブル"、jsessionid、dwrsessionid)); custrantCachEService.putCacheConStant(constants.push_id+jsessionId、dwrsessionId); }}这就是相当于dwr.xml配置文件中如下所示:
<!doctype dwr public " - // getahead limited // dtdダイレクトWebリモート3.0 // en" "http://getahead.org/dwr/dwr30.dtd"> <dwr> <create creator = "new" javascript = "remote" scope = "アプリケーション" value = "com.g360.bean.security.sessionexpiredparam"/> </create> </lowt> </dwr>
对于com.g360.bean.reconsole.opcost.annualopcosttrequestcontroller来说道理一样、这里就不多做说明了;
dwrservlet来说要使用纯注解配置(不使用dwr.xml)Classs这个参数、而且这个参数是这个注解类的全路径名、而且这个参数是这个注解类的全路径名、这个是特别重要的哦、这个是特别重要的哦、因为、dwr3.0好像还不支持包扫描、不知道是需要什么配置才能实现还是怎么的、如果有哪位仁兄正好看见、也正好知道的话请留言麻烦告诉一下、也正好知道的话请留言麻烦告诉一下、感激不尽啊!欢迎大家有什么不明白的地方或者有什么不对的地方、请随时留言;