当前位置: 代码迷 >> JavaScript >> Spring环境上,JSP中直接调用bean,而不需要对spring进行重新初始化
  详细解决方案

Spring环境上,JSP中直接调用bean,而不需要对spring进行重新初始化

热度:299   发布时间:2012-10-06 17:34:01.0
Spring环境下,JSP中直接调用bean,而不需要对spring进行重新初始化

//首先初始化Spring上下文
?WebApplicationContext springContext = (WebApplicationContext) getServletContext()
???.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
?//获取数据访问对象
?JdbcTemplate jdbcTemplate = (JdbcTemplate)springContext.getBean("jdbcTemplate");

  相关解决方案