js页面的值如何获取?

JavaScript020

js页面的值如何获取?,第1张

首先写获取值的js方法

displayUpload('uploadDiv3'){

// 给相关action传值

window.location='<s:url action="action名称" includeParams="none"/>?接收的参数=uploadDiv3

}

在action中有接受的属性

可使用

String uploadDiv3 = request.getP...("uploadDiv3")

其次

在jsp页面上

onclick="JavaScript:displayUpload(传入的值)"

补充回答:

你想要在哪里判断?

是在jsp页面上

还是java程序中

如果是jsp页面上的话,可以

function displayUpload(uploadDiv3){

if(uploadDiv3==是否等于你的条件){

// 如果等于则

}else{

// 不等于则

}

}

jsp在页面上获取java参数总共有以下方法:

(1)直接在URL请求后添加

如:<a href="thexuan.jsp?action=transparams&detail=directe")直接传递参数, 特别的在使用response.sendRedirect做页面转向的时候,也可以用如下代码: response.sendRedirect("thexuan.jsp?action=transparams&detail=directe") ,可用request.getParameter(name)取得参数

(2)jsp:param

它可以实现主页面向包含页面传递参数,如下:

<jsp:include page="Relative URL">

<jsp:param name="param name" value="paramvalue" />

</jsp:include>

还可以实现在使用jsp:forward动作做页面跳转时传递参数,如下:

<jsp:forward page="Relative URL">

<jsp:param name="paramname" value="paramvalue" />

</jsp:forward>通过这种方式和一般的表单参数一样的,也可以通过request.getParameter(name)取得参数

(3)设置session和request

通过显示的把参数放置到session和request中,以达到传递参数的目的

session.setAttribute(name,value)

request.setAttribute(name,value)

取参数:value=(value className)session.getAttribute(name)

value=(value className)request.getAttribute(name)

需要准备的材料分别有:电脑、html编辑器、浏览器。

1、首先,打开html编辑器,新建html文件,例如:index.html,编写问题基础代码。

2、在index.html中的<script>标签,输入js代码:$('body').append($('.name-price span').eq(0).find('b').text())。

3、浏览器运行index.html页面,此时通过jQuery取到了书名“数值分析”并打印了出来。