![](/img/trans.png)
[英]how to get the variable value of javascript to be pass to the string of java in jsp
[英]How to pass jsp String variable value in javascript and print there
嗨,我想在JavaScript中使用JSP变量值
这是我的代码。
Demo.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String plane="A";
%>
<script>
var planB=<%=plane%>;
c
if(planB==B){
document.write("shakti");
}else{
document.write("sharma");
}
</script>
</body>
</html>
我如何获得所需的输出
使用以下命令更改脚本块:
<script>
var planB = '<%=plane%>';
if(planB === 'B'){
document.write("shakti");
} else{
document.write("sharma");
}
</script>
变化:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.