单击单选按钮重定向到 struts 操作

Redirecting to a struts action on clicking on a radio button

我有一组单选按钮。选择其中一个选项后,我希望它重定向到 Struts 操作。

<form name=termDDL>
            <s:iterator value="filterOptions" var="a">
            <%String [] parts = request.getAttribute("a").toString().split(":"); %>
                <input type="radio" name="selectedOption" value="a" onclick="onOptionSelect()"><%=parts[0]%> <h6 style="color:gray;display: inline;"> <%=parts[1]%></h6><br>

                </s:iterator>
            </form>

并且 javascript 函数 onOptionSelected() 在 body 标记结束之前定义如下。

<script type="text/javascript">
    function onOptionSelect() {
        //document.getElementById("courseDisplayChoice").selectedIndex = 0;
        document.termDDL.action = 'displayProductsInRange.action';
        document.termDDL.submit();
    }
    </script> 

但这并不是重定向到 struts 操作。 我不想为此使用提交按钮。如何在不单击提交按钮的情况下完成此操作

您可以使用 window.location 从客户端重定向到任何地方。

function onOptionSelect() {
    //document.getElementById("courseDisplayChoice").selectedIndex = 0;
    window.location = '/displayProductsInRange.action';
}