如题,我的意思是:
例如,有一个app.war,分别部署在同一个Servlet Server的/a和/b两个Context下,我不想修改war中的配置文件,如何“在war外面”或者说“在Servlet Server中”为这两个应用分别指定配置信息?
即:在/a应用中,读取abc配置参数得到AAA,而在/b应用中读取abc参数可以得到BBB。
使用系统属性是不行的;我试了,在Tomcat环境下可以这样做:
在在$CATALINA_BASE/conf/[enginename]/[hostname]/[webappname].xml中
这样就可以不同的应用中读到不同配置结果了。
我的问题是:
1、是否有别的方法?J2EE体系下是否有别的方式为每个Web应用进行个性化配置?
2、我上面的方法是否在各种Servlet Server或J2EE Application Server中都能实现,例如在WebLogic中如何做?
[b]问题补充:[/b]
To parkerwy: 谢谢你的回答
不过用ServletContextName恐怕不行吧,它是web.xml中<display-name>标签的内容,a和b的应该都一样吧:
String getServletContextName()
Returns the name of this web application corresponding to this ServletContext as specified in the deployment descriptor for this web application by the display-name element.
Returns: The name of the web application or null if no name has been declared in the deployment descriptor.
Since: Servlet 2.3
不过ServletContext.getContextPath()可以分别获得/a和/b
在部署时可以“在war外面”覆盖web.xml中的<display-name>么?</display-name></display-name>