Spring3.x @Value为null

在过滤器Filter里面定义变量 用@Value给其赋值,为什么一直都是NULL

必须是spring管理的bean才能注入

可以参考
[url]https://github.com/zhangkaitao/es/blob/master/web/src/main/webapp/WEB-INF/web.xml[/url]

[code="java"]
shiroFilter
org.springframework.web.filter.DelegatingFilterProxy

targetFilterLifecycle
true

[/code]

DelegatingFilterProxy自动到spring容器里找一个名字为shiroFilter的bean,完成任务

[url]https://github.com/zhangkaitao/es/blob/master/web/src/main/resources/spring-config-shiro.xml[/url]

[code="java"]

<!-- override these for application-specific URLs if you like:-->


<!-- The 'filters' property is not necessary since any declared javax.servlet.Filter bean -->
<!-- defined will be automatically acquired and available via its beanName in chain -->[/code]