Saturday, 15 June 2013

java - Embedded Tomcat 7 passing Spring application context to servlets -


I would like to add the web interface to my Java application, so that I will change it using HTTP.

I have added spring bean for some class in the application context which starts embedded tomat. There is access to this class of course, which makes it. But I would like to store this reference in the Tomcat class ( org.apache.catalina.startup.Tomcat ) so that it can be recovered later in the Servlets, so that I can do something like this: Pre-< Ss (); SomeBeanFromContext sbfc = appContext.getBean ("SBFC", ApplicationContext.class); Sbfc.setSomeProperty (newValue); }}

Any ideas how can I achieve it?

Thank you!

To get the reference of stelling beans, classes with Servlets for ApplicationContext Not required. This dependency injection is used

  @Controller @RequestMapping ("/ mypage") public class SomeClass {@Autowired Private SomeBeanFromContext sbfc; @RequestMapping (value = "/ individualRequest", method = RequestMethod.GET) public string doIndividualRequest (HTTPSERT request) {sbfc.setSomeProperty (newValue); ...}}   

@Controller By using annotated classes, the target web controller provides a complete method of injection of beans in sections.

No comments:

Post a Comment