`
flyfeel
  • 浏览: 9588 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

spring 中获取 servletcontext

阅读更多
今天使用security进行权限控制时,需要用到application中的数据,但是发现无法使用strust2中的actioncontext获取。
个人猜测可能是由于security运行在strust2之前,strust2还未能注册当前请求的ActionContext,所以无法使用它获取application。
下面为spring 中 通过 contextLoader 获取servletcontext的方法:

WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();   
        ServletContext servletContext = webApplicationContext.getServletContext(); 
分享到:
评论

相关推荐

    Spring-for -servletcontext1.0.jar

    Ssh获取ServletContext 只需要更改struts-config action中的type就可以了ru :type="com.uo.spring.SpringDelegatingActionProxy" 大家有什么疑问可以直接去我的blog查看http://blog.csdn.net/chen1255/ 《[正解]Ssh...

    Spring实战之ServletContextResource访问资源文件示例

    主要介绍了Spring实战之ServletContextResource访问资源文件,结合实例形式分析了spring使用ServletContextResource读取与遍历资源文件相关操作技巧,需要的朋友可以参考下

    Spring-Reference_zh_CN(Spring中文参考手册)

    12.2.2. 在Spring的application context中创建 SessionFactory 12.2.3. HibernateTemplate 12.2.4. 不使用回调的基于Spring的DAO实现 12.2.5. 基于Hibernate3的原生API实现DAO 12.2.6. 编程式的事务划分 12.2.7. ...

    Spring中文帮助文档

    6.8.1. 在Spring中使用AspectJ进行domain object的依赖注入 6.8.2. Spring中其他的AspectJ切面 6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ加载时织入(LTW) 6.9. 更多资源 7...

    Spring 2.0 开发参考手册

    6.8.4. 在Spring应用中使用AspectJ Load-time weaving(LTW) 6.9. 其它资源 7. Spring AOP APIs 7.1. 简介 7.2. Spring中的切入点API 7.2.1. 概念 7.2.2. 切入点实施 7.2.3. AspectJ切入点表达式 7.2.4. ...

    spring chm文档

    6.8.1. 在Spring中使用AspectJ来为domain object进行依赖注入 6.8.2. Spring中其他的AspectJ切面 6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ Load-time weaving(LTW) 6.9. ...

    Spring API

    6.8.1. 在Spring中使用AspectJ进行domain object的依赖注入 6.8.2. Spring中其他的AspectJ切面 6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ加载时织入(LTW) 6.9. 更多资源 7...

    Maven整合ssm框架.zip

    ssm整合步骤: 第一步:mybatis单独测试 1.引入mybatis,mysql依赖 2....注意:dao层只有接口。... 整合的要点:就是让springmvc从servletContext中获取spring容器即可 1.在web.xml中配置spring的监听器即可。

    JSP 获取Spring 注入对象示例

    <%@ page import=org.springframework.web.context...ServletContext sc = this.getServletConfig().getServletContext(); ApplicationContext ac2 = WebApplicationContextUtils.getWebApplicationContext(sc);

    EL表达式 (详解)

    表示获取变量的值.区别是[ ]可以显示非词类的变量 2、EL隐含对象 1)与范围有关的隐含对象 与范围有关的EL 隐含对象包含以下四个:pageScope、requestScope、sessionScope 和 applicationScope; 它们基本上...

    在action以外的地方获取dao

    这是在action以外的地方拿ApplicationContext的方法,需要的参数是:ServletContext,在request.getServletContext里能拿到,所以只要有request就能拿到spring配置文件里的bean. 这种方法通常在写组件时用,比如写...

    Java学习笔记-个人整理的

    {2.8}框架中移动的小球}{59}{section.2.8} {2.9}抽象与接口}{59}{section.2.9} {2.10}访问控制}{60}{section.2.10} {2.10.1}类的属性}{60}{subsection.2.10.1} {2.10.2}类的方法}{61}{subsection.2.10.2} {...

Global site tag (gtag.js) - Google Analytics