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新功能,简写.
对象

相关文章
相关标签/搜索