web Filter中使用spring注入的bean
来源:互联网 发布:日本评论上瘾网络剧 编辑:程序博客网 时间:2024/06/05 17:29
方法一:
web.xml配置一个
<filter> <filter-name>DelegatingFilterProxy</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetBeanName</param-name> <param-value>myFilter</param-value> //自己过滤器的名字 </init-param> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>DelegatingFilterProxy</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
方法二:
web.xml配置一个
<filter> <filter-name>myFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>DelegatingFilterProxy</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
方法一或者二不同的地方就是在web.xml中的写法不同而已没有太大的区别,配完web.xml之后还要配置 applicationContext.xml中的bean。
applicationContext.xml配置:
<bean id="myFilter" class="com.MyFilter"> //指名具体的filter类 <property name="service"> //需要注入的具体参数 <ref bean="service"/> </property></bean>
- web Filter中使用spring注入的bean
- web Filter中使用spring注入的bean
- Web Filter中使用Spring注入bean elegatingFilterProxy
- spring Filter中注入bean
- Spring boot 中filter注入bean
- Spring-boot中Filter注入bean
- Web filter中如何引用Spring的bean
- Spring中bean的注入
- spring boot Filter 注入bean
- spring--filter如何注入 spring管理的bean(54)
- servlet 中使用Spring自动注入的bean
- 在filter注入或者是得到spring托管的bean
- Springboot filter 拦截指定的路径(注入spring Bean方式)
- 过滤器中使用spring容器注入bean
- Filter中获取Spring的bean
- Filter中注入spring
- web.xml中filter代码中加载spring中定义的bean
- Spring--多种Bean的注入(中)
- [转]C++还能重新辉煌吗?C++复杂性的思考
- 应晖期末试题大纲
- 如何在串太长时往让其末尾显示一个省略号(在SDI或MDI的View中)
- 手机产品交互体验评估方法
- 设计模式之模板方法模式
- web Filter中使用spring注入的bean
- 实验二、进程管理
- Pipes, Lists & Redirection
- SQLAlchemy指南(tutorial)
- bb
- Tomcat 6.0启动报错java.lang.IllegalArgumentException
- VC 编程技巧 (一)
- 转:16种适合做生意赚大钱的人!
- findbug笔记