Memento definition:
Memento is an object that stores the internal copy of another object. In this way, the object can be restored to the original saved folder.
The memento mode is also easier to understand. We can refer to the following generations:
Public class originator { Private int number; Private file = NULL; Public originator (){} // Create a memento Public memento getmemento (){ Return new memento (this ); } // Restore to the original value Public void setmemento (memento m ){ Number = M. number; File = M. file; } } |
Let's take a look at memento:
Private class memento implements java. Io. serializable { Private int number; Private file = NULL; Public memento (originator O ){ Number = O. number; File = O. file; } } |
The number and file values in originator are saved in memento. By changing the number and file values in the originator call, the restore operation can be performed by calling the setmemento () method.
The memento mode consumes a lot of resources. If there are too many internal memory resources, save a copy of the memory, and you may have to waste a lot of memory.
Application of memento mode in JSP + JavaBean
In JSP application, we usually have many table orders that require using orders, for example, using orders for orders, including names and emails, if some tables do not have a limit or a limit, we hope to query them through the JSP program after using limit to press "Submit submit, when it is found that there is an outstanding case, the text in the case shows a warning or warning. At the same time, you also need to specify the tables that have been imported only by using external tables.
In the following example, the first name is already written in, and the last name has not been written in. In this case, a warning is prompted .:
In fact, this technology utilizes the scope = "request" or scope = "session" feature of JavaBean, that is, the memento mode.
Some examples and examples can be found in the original javaworld English text, while the single-sheet import feature of the JavaBean table can be seen in another article.