Struts 2单个jsp页面执行多种不同的方法

时间:2016-08-12 09:00:34

标签: struts2

我正从struts 1迁移到struts 2框架。基于struts 1 framework parameter = method属性,我可以通过添加隐藏字段"方法"来使用相同的jsp页面执行不同的方法。

如何在struts 2中实现相同的目标?

我的行动课程:

public class MyAction extends ActionSupport {
    public String methodA() {
        return "a";
    }

    public String methodB() {
        return "b";
    }
}

我的JSP页面

<s:form action="MyAction">
    <s:select label="Method Name"
       name="method"
       headerKey="-1" headerValue="Select Method"
       list="#{'01':'A', '02':'B', [...]}"
       value="selectedMethod"
       required="true"
    />
    <s:submit type="button" name="submit" />
</s:form>

1 个答案:

答案 0 :(得分:1)

你可以通过改变&#34;动作来实现这一目标。提交前的网址。

查看通配符方法动态方法调用 here

但是,动态方法调用可以被视为Security Vulnerability

相关问题