Why when I try to use @Autowired does not work Spring a HttpServlet in the transition to the page address?

0 like 0 dislike
32 views
Why when I try to use @Autowired does not work Spring a HttpServlet in the transition to the page neobhodimom at?

web.xml
org.springframework.web.context.ContextLoaderListenerinitcontroller.InitialServletinit/


pom.xml
4.3.13.RELEASEorg.springframeworkspring-web${spring.version}org.springframeworkspring-context${spring.version}org.springframeworkspring-context-support${spring.version}


Servlet
public class InitialServlet extends HttpServlet { private final Logger logger = Logger.getLogger(InitialServlet.class); private final ControllerFactory controllerFactory = new ControllerFactory(); @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String uri = req.getRequestURI(); InternalController controller = controllerFactory.getController(uri); try { if (controller == null) { controller = controllerFactory.getDefaultController(); controller.execute(req, resp); } controller.execute(req, resp); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); try { ((ShowErrorController) controllerFactory.getErrorController()).execute(req, resp,e.getMessage()); } catch (Exception e2) { logger.error("An error has occurred" + e2.getMessage()); e.printStackTrace(); } } } @Override public void init(ServletConfig config) throws ServletException { super.init(config); SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext()); } }
by | 32 views

1 Answer

0 like 0 dislike
Due to the fact that was used to pattern the factory method init is only InitialServlet servlet. This is due to the internal implementation of the method initial(ServletConfiguration) -inside it's configuration determines which servlet name and address will be distributed bin injecting.
by

Related questions

0 like 0 dislike
2 answers
asked Mar 21, 2019 by Ilnur123
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 21, 2019 by SlandShow
110,608 questions
257,187 answers
0 comments
40,796 users