// Annotation-Konfiguration DWR ServletPrivate void initialisierteWrservlet (ServletContext Container) {DWRServlet DWRServlet = new DwrServlet (); ServletRetregistration.Dynamic Dynamic = Container "true"); dynamic.setInitparameter ("pollandCometeabled", "true"); "60000"); dynamic.setInitParameter ("Klassen", DwrannotationClassSconfiguration ()); StringBuffer (); config.Append ("com.g360.bean.Reconsole.opcost.AnnualopcoStrequestController"); config.Append ("); config.Append (" com.g360.bean.security.SessionExpiredParam ");上面我的配置是基于注解版的 DWR Servlet 配置 (将 web.xml 里面的 Servlet 配置转换为了纯 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", CreateorParams = @param (Name = "BeAnname", Value = "SessionExpiredParam")) öffentlicher Sitzungsparam {private statische Logger logger logger = LoggerFactory.getLogger (sessionexpiredParam.class); public boolean isssionExpire (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] push aktiviert", jSessionId, dwrSessionID)); ConstantCacheservice.putCacheConstant (constants.push_id+jSessionId, dwrSessionId); }}这就是相当于 dwr.xml 配置文件中如下所示 :
<! DocType dwr public "-// getahead limited // dtd Direct Web Remoting 3.0 // ede value = "com.g360.bean.security.SessionExpiredParam"/> </create> </duld> </dwr>
对于 com.g360.bean.Reconsole.opcost.AnnualopcostrequestController 来说道理一样 , 这里就不多做说明了; 这里就不多做说明了; 这里就不多做说明了;
对于使用 DWRServlet 来说要使用纯注解配置 (不使用 dwr.xml) 一定要注意在初始化参数时一定要配置 Klassen 这个参数 , 而且这个参数是这个注解类的全路径名 有多个的话就使用逗号分隔 有多个的话就使用逗号分隔 这个是特别重要的哦 这个是特别重要的哦 因为 因为 dwr3.0 好像还不支持包扫描 不知道是需要什么配置才能实现还是怎么的 , 如果有哪位仁兄正好看见 也正好知道的话请留言麻烦告诉一下 也正好知道的话请留言麻烦告诉一下 , 感激不尽啊!欢迎大家有什么不明白的地方或者有什么不对的地方 感激不尽啊!欢迎大家有什么不明白的地方或者有什么不对的地方 请随时留言; 请随时留言; 请随时留言; 请随时留言; 请随时留言; 好像还不支持包扫描 不知道是需要什么配置才能实现还是怎么的 不知道是需要什么配置才能实现还是怎么的 如果有哪位仁兄正好看见 , 这个是特别重要的哦 感激不尽啊!欢迎大家有什么不明白的地方或者有什么不对的地方 , 请随时留言; 请随时留言; 请随时留言; 请随时留言;