weixin_42364416 2010-04-28 11:01
浏览 946
已采纳

如何获得request.setAttribute()中的值

主页面中嵌套了iframe,想把请求的结果传入到iframe中。但我不想用session,有什么办法能够把request.setAttribute("info",info);的值传递给iframe么。感觉iframe是第二个页面一样,request只能将值传递给主页面

  • 写回答

2条回答 默认 最新

  • g_johnson_lee 2010-04-28 16:28
    关注

    试试下面代码:

    [code="HTML"]

    var list = [ <% List list = (List) (request.getAttribute("promotionlist")); for (Iterator it = list.iterator; it.hasNext();) { out.print("\"" + it.next() + "\""); if (it.hasNext()) out.println(", "); } %> ]; document.getElementById("iframeContent").promotionList = list;

    [/code]

    然后到iframe页面,从iframe中取值
    [code="JavaScript"]
    var list = window.top.frames["promotionlist"].promotionList;
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?