js 取得request 中的值(struts jsp action)

1.取變量值
    var a = '<%=request.getAttribute("aaa");%>' ;
2.也能夠將這個值放在頁面上.再取出來.
編程

<input type="hidden" value="<%=request.getAttribute("aaa");%>" id="aaa"/> spa

    var a = document.getElementById('aaa').value ; prototype

(注):對於對象,我推薦使用第二種方法.這樣能夠在頁面中不IMPORT JAVA類..更符合如今編程
    eg:
    <input type="hidden" value="${student.name}" id="stuName"/>
    var stuName = $('stuName').value ;// prototype.js新功能,簡寫.
對象

相關文章
相關標籤/搜索