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.