Настройка Spring Ioc с сервлетами
Я новичок в Spring и хочу подключить Spring ioc к моему небольшому (тестовому) веб-приложению.
У меня есть такой сервлет:ProductServlet
public class ProductServlet extends HttpServlet{
private static final long serialVersionUID = 1L;
private RequestHelper requestHelper;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request);
}
private void processRequest(HttpServletRequest request){
requestHelper.process(request);
}
public RequestHelper getRequestHelper() {
return requestHelper;
}
public void setRequestHelper(RequestHelper requestHelper) {
this.requestHelper = requestHelper;
}
}
и мой web.xml:
ProductServlet
com.epam.productshop.controller.ProductShop
ProductServlet
/ProductServlet
org.springframework.web.context.ContextLoaderListener
contextConfigLocation
/WEB-INF/spring-config.xml
а также у меня есть такая весенняя конфигурация xml:
а у меня такая проблема:
Я хочу, чтобы весной установить объект requestHelper в мой сервлет во время сервлета init (). но вместо этогоs дает мне нулевой указатель.
я пытаюсь реализовать свой сервлет изHttpRequestHandler
, пишуSpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, getServletContext());
в метод init () и другие вещи, которые я вижу в Интернете, но все это не делаетне решить мою проблему.
пожалуйста, помогите мне