八、动态方法的调用和使用通配符定义action

来源:互联网 发布:ppt 触发器 mac 设置 编辑:程序博客网 时间:2024/05/17 23:00
如果action中存在多个方法时,可以使用“!+方法名”调用指定方法,如下:
public class HelloAction{
public String execute(){}
public String other(){}
}
如果访问上面的action的URL路径为:/abc/hello,如果要访问other()方法,可以这样调用:
/abc/hello!other,如果不想使用动态方法调用,可以通过设置常量关闭。


也可以使用通配符定义action,如下:
<action name="hello_*" class="action.helloaction" method="{1}">
</action>
如果要访问other()方法,可以通过这样的URL访问:/abc/hello_other
0 0