spring配置文件路径问题
当spring配置文件不在默认目录下时(具体好像是src目录下),当用ApplicationContext在配置文件中取值,就不能采用ClassPathXMLApplicationContext来取bean的值,只能用FileSystemXmlApplicationContext来读取
?
ApplicationContext ctx=new FileSystemXmlApplicationContext("全路径");
???? 全路径:"WebRoot/WEB-INF/context/applicationContext.xml"
?
?
在web.xml中配置spring的路径
??? 其路径在web-inf/context下
? <context-param>
????? <param-name>contextConfigLocation</param-name>
????? <param-value>/WEB-INF/context/applicationContext-*.xml</param-value>
? </context-param>
?
<listener>
? ??? <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
?
若不用listener,也可以用servlet自启动.