论坛首页 Java企业应用论坛

扩展DWR按目录加载配置文件

浏览 1635 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-04-26  
如果按目录加载多个配置文件,官方提供的做法是修改WEB.XML;如果能够按目录加载配置文件多好,这样就不用修改WEB.XML文件啦。

通过查看DWR源代码,有了一个解决方案供大家参考,直接上源码啦。
1.修改WEB.XML关于DWR的配置

<!-- dwr.  -->
		<servlet>
			<servlet-name>dwr-invoker</servlet-name>
			<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
			<init-param>
				<param-name>debug</param-name>
				<param-value>true</param-value>
			</init-param>
			<init-param>
				<param-name>activeReverseAjaxEnabled</param-name>
				<param-value>true</param-value>
			</init-param>
			<init-param>
				<param-name>initApplicationScopeCreatorsAtStartup</param-name>
				<param-value>true</param-value>
			</init-param>
			<init-param>
				<param-name>maxWaitAfterWrite</param-name>
				<param-value>500</param-value>
			</init-param>
			<init-param>
				<param-name>crossDomainSessionSecurity</param-name>
				<param-value>false</param-value>
			</init-param>
			<init-param>
				<param-name>customConfigurator</param-name>
				<param-value>com.linkage.util.web.DwrDirConfigurator</param-value>
			</init-param>
			<load-on-startup>2</load-on-startup>
		</servlet>
		<servlet-mapping>
			<servlet-name>dwr-invoker</servlet-name>
			<url-pattern>/dwr/*</url-pattern>
		</servlet-mapping>


2.添加com.linkage.util.web.DwrDirConfigurator java实现类

--------------------------------------------------------
官方提供的多配置文件加载方式:
<init-param>
				<param-name>config-system</param-name>
				<param-value>/WEB-INF/classes/dwr/dwr-system.xml</param-value>
			</init-param>
			<init-param>
				<param-name>config-grid</param-name>
				<param-value>/WEB-INF/classes/dwr/dwr-grid.xml</param-value>
			</init-param>
			<init-param>
				<param-name>config-gisPlatform</param-name>
				<param-value>/WEB-INF/classes/dwr/dwr-gisPlatform.xml</param-value>
			</init-param>
			<init-param>
				<param-name>config-spring</param-name>
				<param-value>/WEB-INF/classes/dwr/dwr-spring.xml</param-value>
			</init-param>

论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics