开发基于spring的web程序的时候可能会需要在servlet的filter中得到spring管理的javabean的情况。该如何得到spring管理的javabean呢?
我们应该先得到spring的上下文:ApplicationContext
使用 WebApplicationContextUtils
filter中的代码如下:
public void init(FilterConfig cfg) { ApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(cfg.getServletContext()); this.bean = ctx.getBean(YourBeanType.class); }
参考地址: https://stackoverflow.com/questions/7882042/how-can-i-get-a-spring-bean-in-a-servlet-filter
相关推荐
这篇文档是针对小学六年级英语单元测试题的资料,主要关注的是"如何到达那里"(How can I get there)这个主题。这个单元的学习内容可能包括问路、指示方向、地点名词以及与出行相关的词汇和表达。 1. 单词听力选择...
1.2.1 How can I get/set an environment variable from a program? 1.2.2 How can I read the whole environment? 1.3 How can I sleep for less than a second? 1.4 How can I get a finer-grained version of...
六年级上册英语课件-Unit1 How can I get there? B Let's learn-人教
You'll learn how to bypass the tedious configuration steps so that you can concentrate on your application's behavior., Spring Boot in Action is a developer-focused guide to writing applications ...
六年级上册英语第一单元How-can-I-get-there教案.pdf
You also get a handy command-line interface you can use to write scripts in Groovy. Developers who use Spring Boot often say that they can't imagine going back to hand configuring their applications....
人教PEP版六年级上册小学英语 Unit 1 How can I get there 教案.doc
在人教PEP版六年级上册小学英语 Unit 1 "How can I get there" 的教学过程中,教师针对本单元的教学内容进行了深入的教学反思。这个单元主要涉及的词汇包括邮局(post office)、医院(hospital)、书店(bookstore...
这篇内容主要涉及的是小学六年级英语学习的一部分,具体是人教版PEP教材Unit 1《How can I get there》的综合测试。这个单元的学习重点是关于方向、位置以及如何到达某个地方的表达,同时也包含了词汇学习和基本的...
根据提供的文件信息,本文将对《Unit1 How can I get there?》这一精美学习课件中的关键知识点进行详细的解析和扩展。本课件主要围绕如何询问及指明方向这一主题展开,通过学习新词汇和句型,帮助学生掌握基本的方向...
这篇文档是关于小学六年级英语上册Unit1 "How can I get there?"的教学设计,旨在帮助学生掌握与问路和指示方向相关的英语表达。以下是详细的知识点解析: 1. **核心词汇与短语**: - 学生需要学习并掌握如`...
(人教PEP)6年级英语上册unit1《How can i get there》单元检测 (2) 含答案(含听力材料).doc
You'll learn how to bypass the tedious configuration steps so that you can concentrate on your application's behavior., Spring Boot in Action is a developer-focused guide to writing applications ...
Appendix A covers how to set up your desktop development environment so that you can run all the code examples in this book. This appendix covers how the local build process works and also how to ...
You will master powerful techniques like embedding a Spring container inside an OSGi bundle, and see how Spring's dependency injection compliments OSGi. Along the way, you'll learn to handle data ...