| |

VerySource

 Forgot password?
 Register
Search
View: 12|Reply: 2

What is redirect = "true" set to?

[Copy link]

1

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 Invalid IP Address

Post time: 2020-3-5 17:30:01
| Show all posts |Read mode
There is such a piece of code in struts-config.xml:
<action input = "/ error.jsp" path = "/ adminLogout" scope = "request" type = "com.laoer.bbscs.web.action.AdminLogout">
<forward name = "adminlogin" path = "/ adminlogin.jsp" redirect = "true" />
</ action>
--------------------------
Why is redirect = "true" used in the <forward /> parameter?
What is redirect = "true" set to?
The request and action used for redirect = "false" are very different.
First, thank you!
Reply

Use magic Report

0

Threads

9

Posts

9

Credits

Newbie

Rank: 1

Credits
9

 China

Post time: 2020-5-22 15:15:01
| Show all posts
ActionMapping

ActionMapping will classify the effective business logic in the Struts application. When a request arrives, the ActionSevlet looks up the corresponding information in the ActionMapping directory. ActionMapping is a core design of Struts applications. When you need to understand a Struts application or write a new Struts application, you should start with ActionMapping. ActionMapping has more attribute information, please refer to related documents for details.

ActionForward

ActionForward is one of the core classes of Struts, and its base class has only 4 attributes: name / path / redirect / classname. In the development process of Web applications based on Struts, after the Action operation is completed, the program will be linked to the specified ActionForward through the Struts configuration file struts-config.xml, and passed to the core class ActionServlet of Struts. The ActionServlet uses the path provided by ActionForward to control Pass to the next step. ActionForward controls the direction of the next program. ActionForward represents the URI of an application, which includes the path and parameters, for example:

path = "" / modify.do?method=edit&id=10 "

In addition to setting the parameters of ActionForward in struts-config.xml and the page, you can also add parameters in the Action class or recreate an ActionForward in Action.

There is an important attribute redirect in ActionForward. When redirect = false, all the content stored in the http request and request context will be saved and only available in the same application. When redirect = true, the web client makes a new http request, the requested resource can be in the same application or not, the original request parameters are no longer saved, the original request context is also cleared, and the new http request Only include the parameters contained in the path attribute of ActionForward. If in the same application, the context of the user session will be maintained.

ActionForward is divided into global forwarding and local forwarding. The findForward method of Action's Mapping object will first check the local forwarding list, and if it fails to find, it will look in the global forwarding list. In the writing format, we generally define global variables as String constants to avoid misunderstandings and make the forwarding list structure clear and easy to read.

During the project development process, a situation is often encountered. When the page has changed, the address in the browser such as /modify.do or /modify.jsp has not changed. At that time, it was not considered so fine. Although there is doubt, it has no effect To realize the function of the program, so I ignored it. I found some information today to find out. The client browser displays the last URL given to the browser. After the URL is submitted, the web application may have forwarded the request multiple times before a component returns a response to the browser, and these processes all occur on the server. At the end, the client browser does not know what has changed. When an http response is returned, it does not contain the value of the address bar, so the browser only displays the address it used as the initial request. By using redirect, you can change the display of the browser address, because this can submit a new request to the browser, but the price paid is that the data cannot be passed to the page through the request context, which is also one of the differences between using forward and redirect.
Reply

Use magic Report

0

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-6-2 22:00:02
| Show all posts
Redirect
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list