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

时间:2013-09-10 10:49:56

标签: javascript jstl

我在Spring MVC工作。我不知道在jstl标签中使用javascript变量。 我的功能,

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

表示jstl标签,

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

我想在deliveryname =的末尾使用变量alert1 有人请帮助我,非常感谢

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

<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>