简体   繁体   English

我如何在jstl标签中使用javascript变量

[英]How can i use javascript variable in jstl tag

i am working in Spring MVC. 我在Spring MVC中工作。 i have no idea to use javascript variable in jstl tag. 我不知道在jstl标签中使用javascript变量。 my function, 我的职能

function funcAlert(){
        var alert1 = document.querySelector('input[name = "deliverystatus"]:checked').value;
        alert(alert1);
    }

for the jstl tag, 对于jstl标签,

<c:url var="selectDeliveryman" value="/admin/order/selectDeliveryman?id=${orderAttribute.orderId}&deliveryname=" />

i want to use variable alert1 in the end of deliveryname= anyone please help me, alot of thanks 我想在deliveryname =的末尾使用变量alert1,请任何人帮助我,非常感谢

您可以简单地用作${alert1} ,但是您需要在脚本中全局声明它,并确保alert1作为服务器端运行,因此您只能获取alert1值,该值在页面加载期间初始化,然后您对该变量,您无法在jstl中获得它。

<c:url var="selectDeliveryman" value="/admin/order/selectDeliveryman?id=${orderAttribute.orderId}&deliveryname=" />

<script>
function submit() {
   var alert1 = document.querySelector('input[name = "deliverystatus"]:checked').value;
   document.location="${selectDeliveryman}"+alert1;
}
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM