i want to use spring autowiring in servlet so here\'s my code:
@Configurable
public class ImageServlet extends HttpServlet {
@Autowired
private Syst
Remove the @Configurable
annotation from your servlet and add:
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext (this);
at the first line of your init() method.
I followed the solution in the following link, and it works fine: Access Spring beans from a servlet in JBoss
public class MyServlet extends HttpServlet {
@Autowired
private MyService myService;
public void init(ServletConfig config) {
super.init(config);
SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this,
config.getServletContext());
}
}