What's the best approach to persist form data using Struts 2?

寵の児 提交于 2021-02-08 10:17:36

问题


I am developing an application using Struts 2 and Hibernate.

On a JSP page I have one form in which all CRUD operations I am performing. I want my Form data to be persisted, which is temporarily entered in the form fields.

One approach which I tried is to bind all the data into an Object and store that object in a session or cache but I know there is some limitation of storing data like this. My form is having the functionality to add n number of rows which means I have to store large amount of data if I use session approach.

So is there any alternative and effective way to do this and yes in a easy manner?


回答1:


Don't use much data in session if you don't need that data anymore. You also need it to implement Serializable whatever you use a session.

If you are using CRUD application, the data should be available immediately after you save it to the database. Hibernate allows you to get the data from the session.

Don't mess it up with http session. And if the data is not available in the hibernate session hibernate will fetch the data and store it in the cache, then it return the data to you.



来源:https://stackoverflow.com/questions/34481022/whats-the-best-approach-to-persist-form-data-using-struts-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!