What does actionforward do? It is used to encapsulate the forwarding and redirection paths.
In Struts-config. <forward name = "error" Path = "/login. JSP "> </forward> 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". If it is set to true, it becomes redirection. The error page is the page to jump to when a site error occurs, so you should use redirection for the instance. Change the address to the address on the error page.
<Forward name = "error" Path = "/error. jsp" Redirect = "true"> </forward>
Define global forward: use the label <global-forwards> to define global forward: <global-forwards>
<Forward name = "login" Path = "/login. jsp" Redirect = "true"/>
</Global-forwards> global forward can be selected by region. However, when you need to use forward, Struts automatically selects the nearest node. When there is also a definition of the local, it will be converted according to the local. Therefore, public content can be defined globally, such as errors and logon processing. Dynamic actionforward: the static actionforward cannot be changed during the execution period. The callback can be modified during the execution period by using dynamic actionforward.
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;
Static actionforward URLs cannot be added with the number of shards. Dynamic actionforward can be used with the number of shards. 1. Correct Use of forwarding and redirection will make the site URL display more friendly.
2. The configuration of appropriate global actionforward is much more convenient.
3. It is good at using dynamic actionforward and brings convenience to the program.