Introduction to ActionForward in Struts1

Source: Internet
Author: User


What does ActionForward do? It is used to encapsulate the forwarding and redirection paths.

In struts-config. xml The default value is forwarding. The forwarding feature is that the same request is used, and the redirected url address changes, while the forwarded url address remains unchanged. Redirection is redirected from the browser, which means that another request is sent, so the request is not the same, so its url address will change. To change to redirection, you need to use another property: redirect = "true" and set it to true to change to redirection. The error page is the page to jump to when a website error occurs, so you should use redirection for the instance. Change the address to the address on the error page.





Define global forward: use tags To define global forward:





Global forward is accessible, but when you need to use forward, struts automatically selects based on the proximity principle. When the local file is also defined, it is converted according to the local file. Therefore, public content can be defined globally, such as errors and logon processing. Dynamic ActionForward: static ActionForward cannot be changed during runtime. Dynamic ActionForward can be changed during runtime.


String page = request. getParameter ("page ");

ActionForward af = new ActionForward ("/page" + page + ". jsp? Name = wenhq ", true );
// True: Do not use redirection. The default value is false, which indicates redirection.
Return af;


The static ActionForward url cannot contain parameters, but dynamic ActionForward can be used to add parameters. 1. Correct Use of forwarding and redirection will make the website url display more friendly.


2. It is much easier to configure the appropriate global ActionForward.


3. It is good at using dynamic ActionForward and brings convenience to the program.

Related Article

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.