1. Add struts capabilities for the project
A) Right-click the project and choose build path> Add extendal archives.
, Select the following jar package under the Lib folder in the struts2 installation package (the version can be different
You can fix the same content. The figure is 2.1, and the actual project is 2.2)
B) Click Finish. The added project has an additional web. xml file with the core filter added.
.
<? XML version = "1.0" encoding = "UTF-8"?>
<Web-app version = "2.5"
Xmlns = "http://java.sun.com/xml/ns/javaee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemalocation = "http://java.sun.com/xml/ns/javaee
Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd>
<Context-param>
<Param-Name> contextconfiglocation </param-Name>
<Param-value>
Classpath: applicationcontext. xml
</Param-value>
</Context-param>
<Listener>
<Listener-class>
Org. springframework. Web. Context. contextloaderlistener
</Listener-class>
</Listener>
<Welcome-file-List>
<Welcome-File> index. jsp </welcome-File>
</Welcome-file-List>
<Filter>
<Filter-Name> struts2 </filter-Name>
<Filter-class>
Org. Apache. struts2.dispatcher. Ng. Filter. strutsprepareandexecut
Efilter
</Filter-class>
</Filter>
<Filter-mapping>
<Filter-Name> struts2 </filter-Name>
<URL-pattern>/* </url-pattern>
</Filter-mapping> </Web-app>
C) create a file named struts. xml under the SRC folder (used to configure action
): You can directly copy the Struts. xml configuration code in the struts 2.2.2.1 installation package:
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype struts public
"-// Apache Software Foundation // DTD struts Configuration
2.0 // en"
Http://struts.apache.org/dtds/struts-2.0.dtd>
<Struts>
<Package name = "default" namespace = "/" extends = "struts-
Default ">
<Default-action-ref name = "Index"/>
<Action name = "Index">
<Result>
/Index. jsp
</Result>
</Action>
</Package>
</Struts>
2. Add spring capabilities to the Project
A) Right-click the project and choose myeclipse> Add spring.
Capabilities, or click myeclipse-> Project capabilities in the menu bar.
-> Add spring capabilities.
B) Select spring3.0 and spring 3.0 AOP and spring for the class library.
3.0 Core, spring 3.0 persistence core, spring 3.0 persistence
JDBC, spring 3.0 web 5 libraries, and check copy to local WEB-INF/lib directory.
C) Click Next. The default configuration does not need to be modified.
D) Click Finish to view the project after adding spring.
Applicationcontex. xml file
3. Add hibernate capabilities to the Project
A) Right-click the project and choose myeclipse> Add hibernate.
Capabilities, or click myeclipse-> Project capabilities in the menu bar.
-> Add hibernate capabilities.
B) Select hibernate3.3. If you want to enable this feature
Annotation, but it will cause trouble to automatically generate object classes in the future.
Object Class ing in file format. By default, choose hibernate 3.3 annotation &
Entity Manager, Hibernate 3.3 core libraries two class libraries, copy jar
File to the local WEB-INF/lib folder.
C) Click Next and select the configuration file using spring.
Applicationcontext. XML, so that hibernate. cfg. XML is not generated.
Whether or not it depends on your habits.
D) Click Next and select an existing applicationcontext. xml file.
And the name of the sessionfactory.
E) Next, select the established database connection sshtest001
F) Click Next and deselect the check box. The hibernatesessionfactory is not generated.
Class
G) Click Finish to view the project. The applicationcontext. xml file is added.
Database Connection configuration, including datasource and sessionfactory
4. test items:
Right-click the project and choose run as> myeclipse server application.
The "this is my JSP page." Page indicates that the framework is successfully configured.