Integration of Webwork and Spring
1 suitable for readers
This article has a certain understanding of the webwork foundation, the webwork foundation, has a certain understanding of Spring.
Http://www.springframework.org Site can learn more about Spring. Spring is a good AOP framework that provides automatic transaction management.
Http://www.opensymphony.com/webwork/ Site can learn more about WebWork. Webwork is a good MVC framework, which brief introduction, the integration of web and spring, as an example of user registration.
2 integrated steps
2 .1 use SpringObjectFactory
The XWork-Optional on dev.java.net includes support for xwork-spring and can download some packages. There are only 4 classes in the package, which can be used according to the specific situation. I use the SpringObjectFactoryListener class in the example, and the webwork file is added in Web.xml, the following node
listener>
But in practice, you cannot use it, back to write in the SpringObjectFactoryListener class, load some classes must first load the org.springframework.Web.Context.contextLoaderListener class, because some classes are configured in Web.xml, followed by Listener .
servlet>
The role of the ContextLoaderServlet is to load Spring configuration information (in the INT method), the role of SpringObjectFactoryListener is to set up xwork and webwork environments, so that this can load data and information from Spring (in the ContextInitialized (ServletContext Event) method, when the web application is started The program is called).
To make the ContextLoaderServlet earlier than the SpringObjectFactoryListener class, the method I use is to overrunate the ContextLoaderServlet, set the XWork and Webwork environment in the INT method of the neutron, remove the SpringObjectFactoryListener listener, and remember the Spring configuration in Web.xml, as follows :
servlet>
2.2 Configuring Webwork
Add the following nodes in WebWork.xml
/ register-result.jsp param>
result>
/ registersupport.jsp param>
result>
action>
Where RegistersupportBean is configured in Spring
2 .3 Configuring Spring
Join the Action configuration in Spring as follows
Singleton = "false"> Property> bean> Some Registersupportbean In Webwork The class name to be called in.