Struts2.0 Frame Construction Steps

Source: Internet
Author: User

The implementation of the MVC concept of the struts framework, mainly divided into three layers of structure, namely: View->controller->model, three to each other to pass data, to achieve the data in the foreground and backstage conversion, verification, display, storage.

the steps to build the struts framework are as follows:

1. Create a new Java project in MyEclipse, delete the source file src in the project, create a normal file, and copy the jar package extracted from struts into the new normal folder.

2. Create a new Web project, right-select build Path->add jars (not a jar package for external third party) Select the new Java project in the first step and import the jar package into the new project.

3. In the src file directory, create a new configuration file "Struts.xml" and configure it, enter the following code in the editor: (Refer to the import jar package in the Struts2-core-2.3.16.3.jar struts-default.xml)

<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts public    "-//apache software foundation//dtd struts Configuration 2.3//en"    "/http Struts.apache.org/dtds/struts-2.3.dtd ">

4. Configure Struts.xml configuration file, root node <struts></struts> only one group, struts under a set of <package></package> tags, The package has three attributes, name (a packae that can have multiple groups in a struts, must have different names to differentiate), extends (Implementation inheritance, default inheritance of "Struts-default"), Namespace (namespaces, The default is "/" for the address entered in the navigation bar, followed by the action node, the three attribute name (for request name), Class (The entity class that implemented the action), method (the names of the methods that are processed in the entity Class), and finally the result node. The tag body contains the last page returned or the next action.

5. Associate STRUTS2.0 Framework window->perferences-> input XML, select Catlog, select Add option, select File system under location to find the extracted apps-> Web-inf->lib->struts2.3.dtd, OK, key_type select Uri,key paste Http://struts.apache.org/dtds/struts-2.3.dtd, that is, the completion of the association.

6. Configure Web. XML:

<pre class= "java" name= "code" ><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>*.action</ Url-pattern></filter-mapping>

This configuration struts prepares and executes the monitor to start the normal boot of the Struts2.0 framework, and if not configured, a 404 error occurs when the project is deployed to the container!

When the above configuration is complete, the Struts framework is built

Struts2.0 Frame Construction steps

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.