Struts2 Knowledge System

Source: Internet
Author: User

1. What is STRUTS2?

STRUTS2 is the framework for enterprise-class web development, and the development of Web applications based on STRUTS2 will greatly improve development efficiency, scalability, and maintainability.

2, the advantages of struts2

The struts2 Framework is a typical framework for implementing the MVC architecture, using the Struts framework, which makes it easy to configure the data layer (model) through the Struts2.xml file configuration . The control layer and view presentation layer are separated to develop a clearly structured project.

3. Operating mechanism of STRUTS2

See blog: http://www.cnblogs.com/tengpan-cn/p/5210155.html

4. Struts2 Knowledge System

① How to build the simplest STRUTS2 program

In combination with the struts2 operation mechanism, we first configure the STRUTS2 filter in Web. XML, and write the Struts2.xml file (the file can include the others ) The action class (inheriting from the Actionsupport Class) is written in the background, and the front-end display page can be written;

② about problems in Struts.xml configuration

  Package: The role of a package is the same as that of a package in Java, primarily to prevent the naming conflict of an action, especially when multiple teams are responsible for a project;

The package can inherit, and the default (must be written in XML) inherits the Struts-default package;

Namespace property, the value must begin with "/"; corresponds to a part of the URL address in the client browser

  action Tag : In the package label, this label specifies the background logic, the implementation is the control layer ;

Part of the URL address that corresponds to the Name property

Dynamic method Invocation (Application of wildcard *) ~ ~ ~ ~ ~ ~ ~, this technology can be from the client to the server side of the Struts.xml file transfer parameters, to achieve dynamic configuration;

STRUTS2 is thread-safe, and each request to access an action creates a new action object.

  The result tag , located inside the action tag, is used to specify what the foreground displays when the action is finished, and the display layer is implemented;

the default value of the Name property is success;

Type property: Can be set to dispatcher (server jumps to page. jsp. HTML, etc.), redirect (client jumps to page), chain (server-side jump to action), Redirectaction (client jumps to action); default is dispatcher;

about the path in struts : The path in the URL address is not the actual path to the file, that is, the way struts2 looks for the path is not based on the file save path, but on the relationship between the package, action, and result.

   global-result Tag: a package corresponding to a global-result tag, which contains multiple result tags, all the action in this bag can use these result tags;

Other packages want to use these tags, you can inherit this package;

  

  front-end and server-side data interaction :

The front-end passes data to the server:

  

Struts2 Knowledge System

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.