使用 Java 的 HTML5 本地存储访问
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13217423/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML5 Localstorage access using Java
提问by Dev G
Is it possible to access localstorage object using Java directly? If yes how?
是否可以直接使用 Java 访问 localstorage 对象?如果是如何?
Update: I am aware that localstorage is client side and java is server side but I read on net that GWT have api that allow to read localstorage.
更新:我知道 localstorage 是客户端,java 是服务器端,但我在网上读到 GWT 有允许读取 localstorage 的 api。
回答by JB Nizet
The local storage, as its name indicates, stores information locally, which means in the browser, at client-side. The servlet filter executes at server-side. There is no way to access the local storage at server-side.
本地存储,顾名思义,将信息存储在本地,即在浏览器中,在客户端。servlet 过滤器在服务器端执行。无法访问服务器端的本地存储。
If you need to access some ID stored in the local storage from a servlet filter, then retrieve this ID from the local storage in JavaSCript, and send a request containing this ID to the server.
如果您需要从 servlet 过滤器访问存储在本地存储中的某些 ID,则从 JavaSCRipt 中的本地存储中检索此 ID,并将包含此 ID 的请求发送到服务器。
回答by egemen
Localstorage is better alternative thamn Cookie. So, I am waiting JAVA support without external library for accessing local web storage, too. Now I am using sellenium support. Please, look at https://gist.github.com/dariodiaz/5079695
Localstorage 是更好的替代 thamn Cookie。所以,我也在等待没有外部库的 JAVA 支持来访问本地网络存储。现在我正在使用 Selenium 支持。请看https://gist.github.com/dariodiaz/5079695