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

前端之家收集整理的这篇文章主要介绍了扩展DWR按目录加载配置文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如果按目录加载多个配置文件,官方提供的做法是修改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>
原文链接:https://www.f2er.com/ajax/165732.html

猜你在找的Ajax相关文章