"Spring (iii): Spring integration Hibernate" previous article has introduced the use of Spring-framework-4.3.8.release and hibernate-release-5.2.9.final Project Integration building process, this article based on the previous article, the integration of STRUTS2.
Introduction to the development environment:
1), JDK 1.8
2), Spring-framework-4.3.8.release, Hibernate-release-5.2.9.final, struts-2.3.31
- Introducing the STRUTS2 Jar Development package into the new project My-ssh
Unzip the \struts-2.3.31-all\struts-2.3.31\apps\struts2-blank.war file and then Struts-2.3.31-all\struts-2.3.31\apps\ All jar release packages under Struts2-blank\web-inf\lib\ are copied to webcontent\web-inf\lib\ under the MY-SSH project.
After that, you need to see if the jar packages in the webcontent\web-inf\lib\ of the MY-SSH project have duplicate jar packages, and if there are duplicate jar packages, you need to remove the low version jar package (otherwise, a version conflict will occur).
- Add filter to the webcontent\web-inf\web.xml of the MY-SSH project
From \struts-2.3.31-all\struts-2.3.31\apps\struts2-blank\web-inf\ The filter configuration information for Struts2 can be found in Web. XML, and the filter configuration information is copied to the webcontent\web-inf\web.xml of the MY-SSH project.
After configuration, the Web. XML content is as follows:
<?XML version= "1.0" encoding= "UTF-8"?><Web-appXmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns= "Http://java.sun.com/xml/ns/javaee"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"ID= "webapp_id"version= "3.0"> <Display-name>My-ssh</Display-name> <welcome-file-list> <Welcome-file>Index.html</Welcome-file> <Welcome-file>Index</Welcome-file> </welcome-file-list> <!--Configuring the Listener to start the IOC container - <!--needed for Contextloaderlistener - <Context-param> <Param-name>Contextconfiglocation</Param-name> <Param-value>Classpath:applicationContext.xml</Param-value> </Context-param> <!--bootstraps The root Web application context before servlet initialization - <Listener> <Listener-class>Org.springframework.web.context.ContextLoaderListener</Listener-class> </Listener> <!--Struts2 Filter - <Filter> <Filter-name>Struts2</Filter-name> <Filter-class>Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</Filter-class> </Filter> <filter-mapping> <Filter-name>Struts2</Filter-name> <Url-pattern>/*</Url-pattern> </filter-mapping> </Web-app>
- Copy the struts2 configuration file Struts.xml to the Conf of the MY-SSH project
Copy the \struts-2.3.31-all\struts-2.3.31\apps\struts2-blank\web-inf\classes\struts.xml file to the Conf of the MY-SSH project,
and edit to the following content:
<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.3//en" "Http://struts.apache.or G/dtds/struts-2.3.dtd "><Struts> <constantname= "Struts.enable.DynamicMethodInvocation"value= "false" /> <constantname= "Struts.devmode"value= "true" /> < Packagename= "Default"namespace="/"extends= "Struts-default"> </ Package></Struts>
Spring (iv): Spring integrates hibernate, then integrates STRUTS2