admin管理员组文章数量:1355532
I have a form with few filed. Once i submit the form the data is stored in database and i will return to the same page. Now, How to clear the fields in the form??
It is a struts based application. On submit it does some validations using java script then forwarded to the same page. Now, I must get a fresh page. I mean the fields must be cleared.
I have a form with few filed. Once i submit the form the data is stored in database and i will return to the same page. Now, How to clear the fields in the form??
It is a struts based application. On submit it does some validations using java script then forwarded to the same page. Now, I must get a fresh page. I mean the fields must be cleared.
Share Improve this question asked Mar 12, 2011 at 5:38 priyapriya 4,3678 gold badges24 silver badges15 bronze badges6 Answers
Reset to default 2You can override Struts' Action reset()
method and after you used it in your action you can do form.reset(request, response);
and do a forward. That way, your form is resetted.
Can't you just use the javascript reset()
method on the form?
You can have 2 options use on load JavaScript form.reset() or you can clear your formclass fields before returning to your form ie define a reset method in your struts form class call this method before return.
you can clear the form with the reset method of your form.
You can use redirect method like this :
request.setStatus(request.SC_SEE_OTHER);
request.setHeader("Location",url);
Where SC_SEE_OTHER is the proper 303 code and "url" is the url of you current page this will reload your page so all your filed will be reset.
In my case i handle in java action class , you should clear the model or bean object in your java class before return Action.SUCCESS; example customerDetail.setId(""); customerDetail.setName("");
本文标签: javaHow to clear the form after submitting the valuesStack Overflow
版权声明:本文标题:java - How to clear the form after submitting the values? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743942503a2565822.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论