當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Spring 集成web环境
生活随笔
收集整理的這篇文章主要介紹了
Spring 集成web环境
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Spring 集成web環境
一、配置ContextLoaderListener 監聽器
1.maven坐標
org.springframework
spring-web
5.3.14
2.web.xml
applicationContext.xml
二。使用WebApplicationContext 獲取上下文
@WebServlet(name = "testServlet", value = "/testServlet") public class testServlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// ApplicationContext app = (ApplicationContext) request.getServletContext().getAttribute("app");ServletContext servletContext = this.getServletContext();WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);userService bean =webApplicationContext.getBean(userService.class);bean.inke();} 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的Spring 集成web环境的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python计算机视觉编程(全)(强烈推
- 下一篇: 南昌大学2021年811考研真题+答案详