Steps for setting up the struts2 Development Environment
1. Create a project ---- javaweb project.
2. Import the relevant srtuts2 JAR File
3. Create a JSP file
4. Create an action file
5. Compile the srtuts2 configuration file.
<Struts>
<! --/Primer/helloworldaction. Action
Package: Package
* Name: package name, unique, required
* Namespace: The namespace, which is unique and equivalent to the room number. Optional. If not specified, it is "/". The first half of the Request connection in the page
* Extends: Inheritance
* Extends = "struts-Default": struts2-core-2.3.3.jar files under the core package struts-default.xml provided by the bottom layer of the struts2 framework
* Why inherit this struts-default.xml file?
-->
<Package name = "Primer" namespace = "/primer" extends = "struts-Default">
<! --
Action:
* Name: the second half of the Request connection on the page.
* Class: full path of the class to be executed
-->
<Action name = "helloworldaction" class = "cn. itcast. primer. helloworldaction">
<! --
Result: result type.
* Name: the return value of the method of the executed class.
Public String execute () throws exception {
System. Out. println ("helloworldaction ************** execute ()");
Return "success ";
}
* Text Content in the second half: page to be redirected
-->
<Result name = "success">/primer/success. jsp </result>
</Action>
</Package>
</Struts>
6. Add the srtuts2 MVC Framework STARTUP configuration to Web. xml.
<Filter>
<Filter-Name> strutsprepareandexecutefilter </filter-Name>
<Filter-class> org. Apache. struts2.dispatcher. Ng. Filter. strutsprepareandexecutefilter </filter-class>
</Filter>
<Filter-mapping>
<Filter-Name> strutsprepareandexecutefilter </filter-Name>
<URL-pattern>/* </url-pattern>
</Filter-mapping>
Build strut2 Development Environment