spring如何使用多个xml配置文件

胡昊
2023-12-01

1, 在web.xml中定义 contextConfigLocation参数.spring会使用这个参数加载.所有逗号分割的xml.如果没有这个参数,spring默认加载web-inf/applicationContext.xml文件.


<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:conf/spring/applicationContext_core*.xml,
classpath*:conf/spring/applicationContext_dict*.xml,
classpath*:conf/spring/applicationContext_hibernate.xml,
classpath*:conf/spring/applicationContext_staff*.xml,
classpath*:conf/spring/applicationContext_security.xml
classpath*:conf/spring/applicationContext_modules*.xml
classpath*:conf/spring/applicationContext_cti*.xml
classpath*:conf/spring/applicationContext_apm*.xml
</param-value>
</context-param> 



contextConfigLocation 参数定义了要装入的 Spring 配置文件。原理说明如下:
、利用ServletContextListener 实现。
Spring 提供ServletContextListener 的一个实现类ContextLoaderListener ,该类可以作
为listener 使用,它会在创建时自动查找WEB-INF/ 下的applicationContext.xrnl 文件。因
此,如果只有一个配置文件,并且文件名为applicationContext.xml ,则只需在web.xml
文件中增加如下代码即可:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
如果有多个配置文件需要载入,则考虑使用<context-para即元素来确定配置文件的
文件名。由于ContextLoaderListener加载时,会查找名为contextConfigLocation的参数。
因此,配置context-param时参数名字应该是contextConfigLocation。
带多个配置文件的web.xml 文件如下:
<1-- XML 文件的文件头二〉
<?xml version="l.O" encoding="工80-8859-1"?>
< 1-- web.xm1 文件的DTD 等信息一〉
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems. 工口c.//DTD Web Application 2.3//EN"
''http://java.sun.com/dtd/web-app_2_3.dtd''>
<web-app>
<!一确定多个配置文件>
<context-param>
<1-- 参数名为contextConfigLocation…〉
<param-name>contextConfigLocation</param-name>
<!一多个配置文件之间以,隔开二〉
<param-value>/WEB-工NF/daoContext.xml./WEB-INF/application
Context.xml</param-value>
</context-param>
<!-- 采用listener创建Applicat工onContext 实例-->
<listener>
<listener-class>org.spr工ngframework.web.context.ContextLoader
Listener</listener-class>
</listener>
</web-app>


如果没有contextConfigLocation 指定配置文件,则Spring 自动查找application
Context. xrnl 配置文件。如果有contextConfigLocation,则利用该参数确定的配置文件。
该参数指定的一个字符串, Spring 的ContextLoaderListener 负责将该字符串分解成多个
配置文件,逗号","、空格" "及分号";"都可作为字符串的分割符。
如果既没有applicationContext. xrnl 文件,也没有使用contextConfigLocation参数确
定配置文件,或者contextConfigLocation确定的配置文件不存在。都将导致Spring 无法
加载配置文件或无法正常创建ApplicationContext 实例

配置一个spring为加载而设置的servlet可以达到同样效果.
采用load-on-startup Servlet 实现。
Spring 提供了一个特殊的Servllet 类: ContextLoaderServlet。该Servlet 在启动时,会
自动查找WEB-IN日下的applicationContext. xml 文件。
当然,为了让ContextLoaderServlet 随应用启动而启动,应将此Servlet 配置成
load-on-startup 的Servleto load-on-startup 的值小一点比较合适,因为要保证Application
Context 优先创建。如果只有一个配置文件,并且文件名为applicationContext. xml ,则在
web.xml 文件中增加如下代码即可:
<servlet>
<servlet-name>context</servlet口-arne>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</
servlet-class>
<load-on-startup>l</load-o 口-startup>
</servlet>

。带多个配置文件的web且nl 文件如下:
<!-- XML 文件的文件头-->
<?xml version="1.0" encoding="工SO-8859-1"?>
<! -- web.xml 文件的DTD 等信息→
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems , 工口c.//DTD Web Application 2.3//EN"
''http://java.sun.com/dtd/web-app_2_3.dtd''>
<web-app>
<'一确定多个配置文件一>
<context-param>
<!-- 参数名为contextConfigLocation-->
<param-name>contextConfigLocation</param-name>
<!-- 多个配置文件之间以,隔开一〉
<param-value>/WEB-工NF/daoContext.xml, !WEB-工NF/applicationContext.
xml</param-value>
</context-param>
<!一采用load-on-startup Servlet 创建Applicat工onContext 实例一〉
<servlet>
<servlet-narne>context</servlet-narne>
<servlet-class>org.springframework.web.context.ContextLoader
Servlet</servlet-class>
<!一下面值小一点比较合适,会优先加载一〉
<load-on-startup>l</load-on-startup>
</servlet>
</web-app>




2, 使用匹配符


<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>

比如说用到Hibernate,则把hibernate相关的配置放在applicationContext-hibernate.xml这一个文件,而一些全局相关的信息则放在applicationContext.xml,其他的配置类似.这样就可以加载了,不必写用空格或是逗号分开! 


3, 如果使用struts加载多个spring配置文件.下面这个配置的其实也是contextConfigLocation变量.


struts-config.xml里面加这个
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" 
value="/WEB-INF/applicationContext.xml,
/WEB-INF/action-servlet.xml,,,,,,,"/>

4,如果是非j2ee应用直接程序加载.


ApplicationContext act = new ClassPathXmlApplicationContext(new String[]{"bean1.xml","bean2.xml"});

BeanDefinitionRegistry reg = new DefaultListableBeanFactory();

XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(reg);

reader.loadBeanDefinitions(new ClassPathResource("bean1.xml"));

reader.loadBeanDefinitions(new ClassPathResource("bean2.xml"));

BeanFactory bf = (BeanFactory)reg;


===================================================================================================================


项目中碰到了tomgcat中可以启动,而部署到weblogic就无法启动的问题,报找不到applicationContext.xml 文件,报错为:

####<2013-2-27 下午03时29分04秒 CST> <Error> <HTTP> <wu-yw> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1361950144661> <BEA-101216> <Servlet: "context" failed to preload on startup in Web application: "allmedia".
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:180)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:126)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:126)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:269)
	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
	at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:83)
	at javax.servlet.GenericServlet.init(GenericServlet.java:241)
	at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
	at weblogic.security.service.SecurityManager.runAs(Unknown Source)
	at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
	at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
	at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
	at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:521)
	at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1893)
	at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1870)
	at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1790)
	at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2999)
	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1371)
	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:468)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
	at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
	at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
	at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
	at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
	at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
	at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:16)
	at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:162)
	at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
	at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
	at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
	at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
	at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:196)
	at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
	at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)
	at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
	at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
	at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)
	at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)
	at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
	at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:99)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:167)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:126)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:126)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:269)
	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
	at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:83)
	at javax.servlet.GenericServlet.init(GenericServlet.java:241)
	at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
	at weblogic.security.service.SecurityManager.runAs(Unknown Source)
	at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
	at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
	at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
	at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:521)
	at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1893)
	at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1870)
	at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1790)
	at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2999)
	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1371)
	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:468)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
	at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
	at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
	at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
	at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
	at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
	at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:16)
	at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:162)
	at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
	at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
	at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
	at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
	at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:196)
	at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
	at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)
	at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
	at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
	at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)
	at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)
	at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
> 


但是我的应用中并没有这个文件。

所以看了下上边的文章。

web.xml

<!DOCTYPE web-app 
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			/WEB-INF/e5-context.xml, 
			/WEB-INF/e5-controller.xml,
			/WEB-INF/e5-web.xml,
			/WEB-INF/e5-auth.xml,
			/WEB-INF/e5-workspace.xml,
			/WEB-INF/photoinfo-servlet.xml,
			/WEB-INF/allmedia.xml,
			/WEB-INF/allmedia-edit.xml
			<!-- ,
			/WEB-INF/e5-sso.xml -->
		</param-value>
	</context-param>

	<filter>
        <filter-name>SetCharacterEncoding</filter-name>
        <filter-class>filters.SetCharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>
    <filter-mapping>
      <filter-name>SetCharacterEncoding</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
<!--ids config begin -->
<filter>
     <filter-name>TRSIdSSSOFilter</filter-name>
     <filter-class>com.trs.idm.client.filter.GeneralSSOFilter</filter-class>
</filter>
<!-- filter-mapping>
     <filter-name>TRSIdSSSOFilter</filter-name>
     <url-pattern>*.jsp</url-pattern>
</filter-mapping-->
<filter-mapping>
     <filter-name>TRSIdSSSOFilter</filter-name>
     <url-pattern>/e5workspace/*</url-pattern>
</filter-mapping>
<filter-mapping>
     <filter-name>TRSIdSSSOFilter</filter-name>
     <url-pattern>/publish/*</url-pattern>
</filter-mapping>
<!-- TRSIdS SSO Listener, use this for enable timeout-notify -->
<!-- filter>
	<filter-name>FounderUUMSAuthFilter</filter-name>  
	<filter-class>com.founder.auth.web.AuthFilter</filter-class>  
</filter-->
<!-- 
<filter-mapping>
	<filter-name>FounderUUMSAuthFilter</filter-name>
	<url-pattern>/e5workspace/auth.do</url-pattern>
</filter-mapping>
<filter-mapping>
	<filter-name>FounderUUMSAuthFilter</filter-name>
	<url-pattern>/e5workspace/keeplive.do</url-pattern>
</filter-mapping> -->
<!-- e5sso -->
<!-- filter-mapping>
	<filter-name>FounderUUMSAuthFilter</filter-name>
	<url-pattern>/e5sys/sysAuth.do</url-pattern>
</filter-mapping>
<filter-mapping>
	<filter-name>FounderUUMSAuthFilter</filter-name>
	<url-pattern>/e5permission/PermissionProxy.do</url-pattern>
</filter-mapping>
<filter-mapping>
	<filter-name>FounderUUMSAuthFilter</filter-name>
	<url-pattern>/e5auth/AdminPermissionProxy.do</url-pattern>
</filter-mapping>
<filter-mapping>
	<filter-name>FounderUUMSAuthFilter</filter-name>
	<url-pattern>/e5sys/AppChangeProxy.do</url-pattern>
</filter-mapping>
<listener>
	<listener-class>com.founder.auth.web.LogoutSessionDestroyedListener</listener-class>
</listener-->
<!-- TRSIdS SSO Listener, use this for enable timeout-notify -->
<listener>
     <listener-class>com.trs.idm.client.listener.CoSessionListener</listener-class>
</listener>
<!-- Use this for co-application's login form action. -->	
	<servlet>
		<servlet-name>context</servlet-name>
		<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet>
		<servlet-name>load</servlet-name>
		<servlet-class>com.founder.e5.load.Load</servlet-class>
		<init-param>
			<param-name>config</param-name>
			<param-value>e5-config.xml</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
    </servlet>

	<servlet>
		<servlet-name>e5</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<load-on-startup>3</load-on-startup>
	</servlet>

	<servlet>
		<servlet-name>buffalo</servlet-name> 
		<servlet-class>net.buffalo.web.servlet.ApplicationServlet</servlet-class> 
	</servlet>

	<servlet>
		<servlet-name>Jersey REST Service</servlet-name>
		<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
		<init-param> 
			<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
			<param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
		</init-param>
		<init-param>
			<param-name>com.sun.jersey.config.property.packages</param-name>
			<param-value>com.founder.api</param-value>
		</init-param>
		<load-on-startup>4</load-on-startup>
	</servlet>
<!-- Use this for co-application's login form action. -->
	<servlet>
	     <servlet-name>TRSIdSSSOProxyServlet</servlet-name>
	     <servlet-class>com.trs.idm.client.servlet.LoginProxyServlet</servlet-class>
	     <load-on-startup>100</load-on-startup>
	</servlet>
	<servlet>
	     <servlet-name>GetLongUrlServlet</servlet-name>
	     <servlet-class>com.trs.idm.client.servlet.GetLongUrlServlet</servlet-class>
	</servlet>

	<servlet-mapping>
		<servlet-name>Jersey REST Service</servlet-name>
		<url-pattern>/api/*</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>e5</servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>buffalo</servlet-name> 
		<url-pattern>/buffalo/*</url-pattern> 
	</servlet-mapping>
	
	<mime-mapping>
		<extension>xml</extension>
		<mime-type>text/xml</mime-type>
	</mime-mapping>
	
	<servlet-mapping>
	     <servlet-name>TRSIdSSSOProxyServlet</servlet-name>
	     <url-pattern>/TRSIdSSSOProxyServlet</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	      <servlet-name>GetLongUrlServlet</servlet-name>
	     <url-pattern>/idsAgents/GetLongUrlServlet</url-pattern>
	</servlet-mapping>
	 <!-- ids config end -->
	<welcome-file-list>
		<welcome-file>login.jsp</welcome-file>
	</welcome-file-list>
	
	<taglib>
		<taglib-uri>http://jakarta.apache.org/taglibs/i18n-1.0</taglib-uri>
		<taglib-location>/WEB-INF/taglibs-i18n.tld</taglib-location>
	</taglib>
	<taglib>
		<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
		<taglib-location>/WEB-INF/c.tld</taglib-location>
	</taglib>
	<resource-ref>
		<description>allmedia Datasource</description> 
		<res-ref-name>jdbc/E5NEW</res-ref-name> 
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref>
	<!--  
	<resource-ref>
		<description>sso Datasource</description> 
		<res-ref-name>jdbc/E5SSO</res-ref-name> 
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref>-->
</web-app>

原来是
<param-value>
			/WEB-INF/e5-context.xml, 
			/WEB-INF/e5-controller.xml,
			/WEB-INF/e5-web.xml,
			/WEB-INF/e5-auth.xml,
			/WEB-INF/e5-workspace.xml,
			/WEB-INF/photoinfo-servlet.xml,
			/WEB-INF/allmedia.xml,
			/WEB-INF/allmedia-edit.xml
			<!-- ,
			/WEB-INF/e5-sso.xml -->
		</param-value>
中注释的原因,很诡异,去掉就可以启动了。

 类似资料: