繁体   English   中英

如何通过JavaScript在struts中为变量分配值?

[英]How to assign a value to a variable in struts from JavaScript?

早上好,我已经在这个问题上工作了一段时间,但我没有在google中找到解决方案。

有没有一种方法可以从JavaScript向Struts中的变量赋值? 我是与Struts合作的新手,所以花了我一些钱。

这是我正在使用的代码的一部分:

首先在代码的某些部分中,我创建了这个小家伙:

<input type="hidden" name="identificadorProspecto" id="identificadorProspecto" value="-1">

与数据库建立一些连接后,我更新此值

<script language="JavaScript" type="text/javascript" >
    var idContainer = document.getElementById('identificadorProspecto');
    alert("idContainer.value: "+contenedorIdentificacion.value);
</script>

<s:url id="car_suc_xx223" action="listar_sucursales.action" >
    <s:param name="cod_prospecto" value="%{identificadorProspecto}" />
</s:url>

当我收到警报消息时,我没有收到与value="%{identificadorProspecto}"中的value="%{identificadorProspecto}"相同的值(此值具有一些随机值)

您可以使用property标签来实现。 例如

<script type="text/javascript">
    var idContainer = document.getElementById('identificadorProspecto');
    idContainer.value = '<s:property value="%{identificadorProspecto}">'; 
    alert("idContainer.value: "+idContainer.value);
</script>

暂无
暂无

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

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