天天看點

Spring與Web內建Spring內建web應用步驟

在Web項目中,可以使用ServletContext域的初始化方法中去初始化ApplicationgContext對象并存儲ServletContext域中,這樣所有Servlet都能擷取應用上下文對象。

Spring內建web應用步驟

1.配置ContextLoaderListener

er監聽器 需要導入坐标spring-web

并配置全局初始化參數

2.通過WebApplicationContextUtils對象擷取應用上下文對象