//注释配置DWR ServletPrivate void初始wrservlet(servletContext容器){dwrservlet dwrservlet = new dwrservlet(); servletRegistration.dynamic = container.dynamic = Container.AddServlet(“ dwr-invoker”,dwrservoker',dwrservlet),dwrservlet); dynamicic.tyc.setlodarlaine.setlodarlainparamparam; settarploans; dynriptarem dynrian; 2) “ true”); dynamic.setInitParameter(“ pollandCometEnabled”,“ true”); dynamic.setInitParameter(“ activeReereVerseajaxEnabled”,“ true”); dynamic.setInitParameter(“ maxWaitafterWerterWrite” “ 60000”); dynamic.setInitParameter(“ class”,dwrannotationClassSconFiguration()); dynamic.addmapping(“/dwr/*”);} //配置DWR注释类,comma comma comma sameprivate stryprivate drannotation drannotation clannotationClannotationClassSconfiguratigration(stringBuffiguration(New) StringBuffer(); config..append(“ com.g360.bean.reconsole.opcost.annualopcostrequestcontroller”); config..append(“,”,“); com.g360.bean.bean.security.security.seventy.session.session.session.sessessextexpiredparam”)上面我的配置是基于注解版的dwr servlet配置(将web.xml里面的servlet配置转换为了纯java代码配置),当然也包括前端和后端直接交互的类(
com.g360.bean.reconsole.opcost.annualopcostrequestcontroller,com.g360.bean.security.session.sessionexpiredparam
)也是使用注解配置的(dwr注解配置,@@remoteproxy,@remetemethod),这对于有些注解配置基础的同学来说可能比较容易看懂,对于初次接触的有什么不懂的可以给我留言哦;
com.g360.Bean.Security.Session ExpiredParam::
@component(“ session expiredparam”) @someoteproxy(creator = springCreator.class,scope = scripsscope.application,name =“ remote”,creatorParams = @params = @param(name =“ beanname”,value =“ value =” sessigriedparam”) public boolean Issessionexpire(string sessionID){return null == constantCacheservice.getCacheConstant(sessionID); } @RemoteMethod public void setEnabledWrupDate(strimentsessionId){scriptSsessionSessionsession = webcontextfactory.get().getScriptsession();字符串jsessionId = scriptsession.gethttpsessionid();字符串dwrsessionId = scriptsession.getId(); logger.info(string.format(“ set jsessionId = [%s],dwrsession = [%s]启用启用启用”,jsessionId,dwrsessionId)); constantCacheservice.putcacheconstant(constants.push_id+jsessionId,dwrsessionId); }}}这就是相当于dwr.xml配置文件中如下所示::
<!Doctype dwr公开” - // getahead Limited // DTD直接Web远程远程3.0 // en”“” http://getahead.org/dwr/dwr/dwr/dwr/dwr30.dtd“> <dwr> <dwre> <belife> <create create creator =“ new” new“ new” javascript =“ value =“ com.g360.bean.security.sessesseviriedparam”/> </> </create> </lose> </dwr>
对于com.g360.bean.reconsole.opcost.annualopcostrequestController来说道理一样,这里就不多做说明了;,这里就不多做说明了;
对于使用dwrservlet来说要使用纯注解配置(不使用dwr.xml)一定要注意在初始化参数时一定要配置类,而且这个参数是这个注解类的全路径名