【发布时间】:2016-10-20 19:29:55
【问题描述】:
我正在尝试将 cookie 从 spring 控制器检索到 jsp 页面的 javascript 代码。这是控制器代码
@CookieValue(required = true) String data) {
System.out.println("this is the sound cookie value>>>>>> " + data); //this prints the xyz cookie value to the console
现在在我的jsp页面的javascript中,我试图以这种方式检索cookie
var cokdata= "${cookie['data']}";
console.log("value>>>>>>> "+cokdata); //it returns nothing
请问如何在 jsp 页面的 javascript 代码中检索 cookie 值
【问题讨论】:
-
我不知道这个注解,但这可能是问题所在,EL是正确的(请添加此方法的完整代码)
-
@Senthilnathan 看看这个...stackoverflow.com/questions/19116040/getting-cookie-in-jspget 是正确的!
标签: javascript java jquery jsp cookies