I have a Struts BaseAction class from which my other Actions are extended. In the BaseAction I have code like:
Code:
private WebApplicationContext wac;
public void setServlet(ActionServlet actionServlet) {
super.setServlet(actionServlet);
ServletContext servletContext = actionServlet.getServletContext();
wac = WebApplicationContextUtils
.getRequiredWebApplicationContext(servletContext);
myManager = (Manager) wac.getBean("myManager");
}
protected Manager getManager() {
return myManager;
}
So in my Actions, I simply call getManager() to get the Spring configured manager.
Spring has some helper classes for Struts integration, but I haven't tried them yet. The above works for me.
Will