How to inject a property value into a filter?
<p>My question is simple. I'm trying to inject a property value into a filter. In my controller class, I used the following code and I could inject the property successfully:</p>

<pre><code>@Controller
public class StatementController {
    @Value("${xapi.version}")
    private String version;
...
}
</code></pre>

<p>but when I use the same code in a custom filter,I get a null value in version property. This is the code:</p>

<pre><code>public class HeaderFilter extends OncePerRequestFilter {

    @Value("${xapi.version}")
    private String version;
    private Logger logger = Logger.getLogger(this.getClass());

    @Override
    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
logger.error(version==null);
...
</code></pre>

<p>I'm using springframework 4.0.9 and this is a fragment of my filter configuration in web.xml:</p>

<pre><code>&lt;filter&gt;
        &lt;filter-name&gt;header&lt;/filter-name&gt;
        &lt;filter-class&gt;com.application.HeaderFilter&lt;/filter-class&gt;
    &lt;/filter&gt;
&lt;filter-mapping&gt;
        &lt;filter-name&gt;header&lt;/filter-name&gt;
        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
</code></pre>