如何从Jquery函数中设置struts2中的变量

How to set a var in struts2 from Jquery function

本文关键字:设置 struts2 变量 函数 Jquery      更新时间:2023-09-26
 fngetThings(thingId)//getting thingId from the included jsp page
    {
    var test1 = thingId;//I need to set this test1 value to a  in the same asp page
    $("#test2").val(test1);
    }

在同一个Jsp页面。

    If i use the below tags it is working fine 
    <s:textfield name="test2" id = "test2"></s:textfield>
    or
    <s:hidden name="test2" id = "test2"></s:hidden>

我无法在变量中设置test1值<s:set var="testVar2" value="" id="test2"/>我需要在某些测试条件下使用test1值。

我试着在函数中写$("#test2").attr("value",test1),这也不起作用。

有人能帮我一下吗?

<s:set var="testVar2" value="" id="test2"/> //how to set value=test1 from script.

你试过了吗

<s:set var="testVar2" id="test2"/>

然后打印<s:property value="testVar2"/>