简体   繁体   English

如何在Web sql中存储列表或在浏览器中存储任何类型的存储

[英]How to store a list in the web sql or any type of storage in the browser

如何在Web sql或浏览器中的任何类型的存储中存储列表,我发现了三种在浏览器中存储数据的方式,即localstorage,会话存储和带有html5的web sql,因此我需要存储java.util。在浏览器中列出列表,以后需要对其进行修改,那么有什么办法吗?

I'm not sure - you need to store and manipulate the 'List' on the server or on the client? 我不确定-您需要在服务器或客户端上存储和操作“列表”吗?

In the first case you may use session. 在第一种情况下,您可以使用会话。 In second case you can't use session because you can not access session variables in javascript. 在第二种情况下,您无法使用会话,因为您无法在javascript中访问会话变量。

In such situation I'm usually creating hidden field (if it's something page related) or cookie (if it's something application related). 在这种情况下,我通常会创建隐藏字段(如果是与页面相关的内容)或cookie(如果是与应用程序相关的内容)。 Using base64 you may pass transformed to string List to the client, modify them and save. 使用base64,您可以将转换为字符串List传递给客户端,对其进行修改并保存。 Of course later you may read the data on the server. 当然,以后您可能会在服务器上读取数据。

我得到了答案,我们需要首先在页面的本地var中获取列表,然后通过javascript对其进行迭代并存储在本地浏览器数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM