//首先初始化Spring上下文
WebApplicationContext springContext = (WebApplicationContext) getServletContext()
.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
//获取数据访问对象
JdbcTemplate jdbcTemplate = (JdbcTemplate)springContext.getBean("jdbcTemplate");
Spring环境下,JSP中直接调用bean,而不需要对spring进行重新初始化
最新推荐文章于 2024-07-08 00:01:13 发布