Struts2 execution process:
After the server is started, the user enters the action path to be requested in the address bar of the browser to access the web project on the server,
The built-in filter of struts2 captures the url address and performs conditional filtering. Locate from struts. xml based on the qualified request
Find the corresponding action, and then execute the corresponding action instance.
Seven core packages added by struts2: (packages may be different based on different versions)
1. Commons-fileupload-1.2.1.jar -------------- upload files
2. Commons-io-1.3.2.jar -------------- upload files
3. Commons-logging-1.0.4.jar
4. Freemarker. jar -------------- presentation layer framework, which defines the topic of the visual component of struts2
5. Ognl. jar -------------- OGNL Expression Language. struts2 supports this EL
6. Struts2-core.jar -------------- core library of struts2 2.0.11.2
7. Xwork. jar ------------ core library of webwork
Procedure:
1: import the six packages that struts2 depends on;
Note: Do not import unnecessary packages during package export. Otherwise, package conflicts may occur. Alternatively, you cannot directly copy the package from another project in MyEclipse. You must find the package from the original file before copying it.
2: add the struts 2.1 feature-> struts. xml configuration file.
Change the <filter-class> self-contained in the struts. xml file to the following content (filter writing in the earlier version of struts2 ).
<Filter-class>
Org. apache. struts2.dispatcher. FilterDispatcher
</Filter-class>
3: add an entity object.
4: Add and implement the dao interface.
5: Add and implement the service interface, and use the method in dao.
6: Add action and use the method in service.
7. Add an input/output view.