Talking about the disposition of struts2

Source: Internet
Author: User

Accounting for 134 Chen Yi

What does Struts 2 know about

Struts 2 is the next generation of struts and is the new Struts 2 framework that was combined with struts 1 and webwork technology. Its new Struts 2 architecture differs greatly from the architecture of struts 1. Struts 2, with webwork as its core, uses interceptors to handle user requests, and the design allows the business logic controller to completely disengage from SERVLETAPI, so struts 2 can be understood as WebWork's updated product. Although there are too many changes from struts 1 to struts 2, the changes are small with respect to the Webwork,struts 2.

Configuring Struts 2 in MyEclipse

Create a new Dynamic Web project on the project right click on select Add Struts capabilities ... The exact operation is shown in

After clicking on the interface shown in the pop-up, the configuration will eventually generate a struts.xml file.

Configuring the Response File (action) in the Struts.xml file

The package node is a central part of the overall configuration. Each package , in fact, represents each individual module in terms of semantics. In this module, you can define the behavior that is subordinate to this module, and it is not related to the other modules. Therefore, each package has a separate definition of interceptor, Result-type,and action, and the vast majority of runtime configuration definitions are implemented through the package node.

1. Name

The Name property sets a unique identity for each package, which cannot be duplicated in all package definitions.

2. Abstract

The definition of the package is an abstract definition that allows him to include only declarative definitions, without having to include the definition of action in the package definition .

3. Extends

By using extends, you can specify that the package inherits all of the other package's configurations. When a package inherits all the configuration from another package , you do not need to define the configuration definitions that have already been declared in the parent package.

Also, if you repeatedly define a configuration definition that has already been declared in the parent package, these duplicate definition declarations will overwrite the related definitions in the parent package.

With the action tag, you can allow the action to be called directly in the JSP page because the action needs to be called, so you can specify the name and namespace of the action that needs to be called. If the property value of the Executeresult parameter is specified to True, the label also includes the action's processing result (view support) in this page.
Properties of the action tag:
ID: An optional attribute that will be the reference ID of the action
Name: Required property, specifies which action the label calls

Class: Required property, specifies that the action tag calls that Java class.
Namespace: Optional, specifies the namespace of the action to which the tag is invoked.
Executeresult: Optional, specify whether you want to include the action results page of the actions on this page. The default is false, which does not contain
Ignorecontextparams: Optional, which specifies whether the request parameter in the page needs to be passed in to the invoked action, and the default is false, passing the request parameter of this sheet to the invoked action.

The result label is used to receive results from the daemon execution

Name: The result returned by its value bit background when the result returned in the background is the same as the name value is the execution of the jump. Such as:

<result name= "Success" >studentmassage.jsp</result>

The system jumps to the studentmassage.jsp page when the background Java code returns success

Talking about the disposition of struts2

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.