如何将 struts2 文本字段的值作为 href 中的参数传递?



我有一个文本字段和一个链接()。我需要将文本字段的值传递给操作类。在我的操作类中,我需要获取文本字段的值作为参数(request.getParameter())

<s:textfield name="input" value="1" label="Qty"/>
<s:a href="OrderReview?&input=/*text field value as a parameter*/">Buy</s:a>

我需要在我的操作类中获得文本字段的值,例如

request.getParameter("input");

这可能吗?如果是,我该怎么做?

提前感谢!

点击锚点时调用javascript函数,获取textfield的值并设置锚点的href。

As,

<s:textfield id="input" name="input" value="1" label="Qty"/>
<s:a href="OrderReview?&input=" onclick="getInputValue(this);">Buy</s:a>
function getInputValue(obj){
    var inputValue = document.getElementById('input').value;
    if(obj.href.indexOf(inputValue) == -1){
        obj.href += inputValue;
    }
}

最新更新