spring入门

it2022-05-09  26

spring的配置文件applicationContext.xml的位置是任意的,可以放在classpath下也可以放在webContent下,只需要在web.xml中配置即可

例如:在webContent中则

1    <context-param> 2 <param-name>contextConfigLocation</param-name> 3 <param-value>/WEB-INF/applicationContext.xml</param-value> 4 5 </context-param> 6 <!-- 监听器 --> 7 <!-- 配置spring监听器 --> 8 <listener> 9 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 10 </listener>

在classPath下则:注意要添加classPath

   <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- 监听器 --> <!-- 配置spring监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>

 

转载于:https://www.cnblogs.com/s413574930/p/3319145.html

相关资源:Spring入门经典

最新回复(0)