`
pengjianbo1
  • 浏览: 229526 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

如何在JSP中使用Spring

    博客分类:
  • JSP
阅读更多

JSP中使用Spring其实很容易,主要用到Spring的WebApplicationContextUtils.getWebApplicationContext函数。

要再JSP里面得到ApplicationContext需要这么做.
首先
import="org.springframework.web.context.support.*,org.springframework.context.*"
然后可以通过如何做法:

ApplicationContext  ctx  =  WebApplicationContextUtils.getWebApplicationContext(getServletContext()); 

 
这样就得到了ApplicationContext,就可以操作Spring了。

JSP本来就可以认为是一个Servlet,所以使用getServletContext()就是理所应当了。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics