I am facing an interesting issue. If you could enlighten me about this, I will appriciate.
Here's a scenerio; I am using Custom Filter in Spring context. I specified it as a DelegatingProxyFilter. So I made Spring context aware of this filter as a bean. I can use @Autowired
annotation for ApplicationContext
class and TranslationUtils
class as you have seen bin the below code. But I can not use @Autowired
with
CommonsMultiPartResolver(**org.springframework.web.multipart.commons.CommonsMultipartResolver**).
Spring container can not inject it. If there is something that I have missed , Please let me know .
Code pieces Here is my filter :
@Component(value = "multipartExceptionHandlerFilter")
public class MultipartExceptionHandler extends OncePerRequestFilter {``
@Autowired // working !!
private TranslationUtils trans;
@Autowired // working !!!
private ApplicationContext applicationContext;
@Autowired // not working !!
@Qualifier("filterMultipartResolver") // also not working !!!
CommonsMultipartResolver commonsMultipartResolver;
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
//do something
}
}
}
filter described in web.xml :
<filter>
<filter-name>multipartExceptionHandlerFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>multipartExceptionHandlerFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Here is bean definition :
<!-- Configure the multipart resolver -->
<bean id="filterMultipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
p:maxUploadSize="52428800" p:defaultEncoding="UTF-8"/>
So what could be the problem?