[Tips] How to automatically empty Struts form

xiaoxiao2021-03-06  57

For a need, the FORMBEAN's Scope is set to session. After performing action, I found the list data on the previous input. Is there any way to automatically empty a single field?

I have thought about it for a while, the problem is solved. It turns out that the problem of , but the problem of FormBean itself. If the FORMBEAN's Scope is request, it is only created when the request occurs, and it is abandoned after the request is completed. Since the FormBean's Scope is Session, it is created when the user builds a session with the server, and it has always been life during the entire session. If its attribute value is not empty, it will naturally be reflected in in it.

My solution is to manually empty the properties of FORMBEAN after executing the database operation:

... String SQL = "Insert Articles VALUES (','" myform.gettitle () "','" myform.getcontent () "" NULL, " "); "; INT i = mysql.executeUpdate (SQL); myform.settitle (null); MyForm.SetContent (null); ......

转载请注明原文地址:https://www.9cbs.com/read-118671.html

New Post(0)