Build strut2 Development Environment

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.