繁体   English   中英

使用javasccript将会话从一个jsp页面传输到另一页面

[英]transfer session from one jsp page to another using javasccript

在我的Spring Java应用程序中,我尝试使用javascript将检索到的Java会话从一个页面转移到另一个页面,这是第一个jsp页面中的尝试

    <script>

//$(document).ready(

function getNotify() {

    <% String mp = (String) request.getSession(false).getAttribute("sound"); %>
        var mp = "<%= mp %>";
        console.log("value>>>>>>> "+mp);//returns the actual value

    <%  request.getSession().setAttribute("sound7", mp);  %>


}

setInterval(getNotify, 2000);

</script>

在第二个jsp中,我试图像这样检索会话,但它返回null

<% String postSound = (String) request.getSession(false).getAttribute("sound7"); %>
    var postSound = "<%= postSound %>";
    console.log("value of postSound>>>>>>> "+ postSound );

请如何使用上述方法将会话从jsp A转移到jspB。

控制器中的@SessionAttributes呢?
检查这个https://github.com/ielatif/stackoverflow/tree/master/SpringMvcExample

暂无
暂无

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

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