Discussion on several ways to realize parameter transfer between different pages
- 2021-07-21 05:40:08
- OfStack
Discussion on several ways to realize parameter transfer between different pages (Li Sheng)
Because web system uses http protocol to transmit data between browser and server, while http protocol is a stateless protocol, there are several ways to transmit data between different pages
Mode 1: Pass in form mode
Form passing parameters is the simplest and most basic way to pass parameters. Note: Use of the form element hide button
Mode 2: url mode with parameters
url with parameters: url? Parameter name 1 = value 1 & Parameter name 2 = value 2.
Mode 3: Request an request object
You can bind data to an request object and read and write through the request object getAttribute and setAttribute methods
Mode 4: User session session object
You can bind data to an session object and read and write through the session object getAttribute and setAttribute methods
Mode 5: application object
You can bind data to an application object and read and write through the getAttibute method and setAttribute method of the application object
Mode 6: cookie object
You can write data to the client browser cookie file.
Among them, Mode 1 and Mode 2 can only transfer string parameters, and Mode 3, 4, 5 and 6 can transfer objects (Mode 6 needs to store objects after serialization)
Mode 1, Mode 2 and Mode 3 data transfer can only request pages to obtain data, while Mode 4, Mode 5 and Mode 6 can obtain data objects on multiple different pages
The data objects stored in Mode 4 and 6 are all information related to a certain user. The difference is that Mode 4 stores data in server memory and Mode 6 stores data in client memory.
The data objects saved in Mode 5 are all information related to all users, and the data is also saved in the server memory