在我的jsp中,我使用 <%String base = (String)application.getAttribute("base");%>
我试图在JavaScript中使用“ base”,但无法正常工作。以下是我的JavaScript:
<script>
var newBase = <%=base%>;
</script>
有人可以帮我解决这个问题吗?
您可以这样尝试,
将值设置为hidden
,
input type="hidden" id="hidVal" name="txt2" value="${base}"/>
在您的Java脚本中,
<script>
var x = document.getElementById('hidVal').value;
alert(x);
</script>
更新:
var newBase = '<%=base%>';
您缺少将这些值视为string的引号。
希望这可以帮助 !!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句