struts2动态方法调用学习笔记一

struts2动态方法调用三种方式:

在struts配置文件中不指定方法。

1,URL?method:methodname

eg:http://localhost:8080/web02/HelloWorld/hello.action?method:addInput

2,URL?action_name!method_name.action

eg:http://localhost:8080/web02/HelloWorld/hello!addInput.action

TIP:这两种方式,记住要在struts.xml配置文件里面设置相应常量项

<constant name="struts.enable.DynamicMethodInvocation" value="true" />

将struts.enable.DynamicMethodInvocation设置为true

3,通配符方式

<action name="hello_*" class="cn.cj.action.HelloAction" method="{1}">
<result name="hello">/Hello.jsp</result>
</action>

其中action的name属性hello_*_*里面的*依序对应method的{1}_{2}

posted @ 2013-11-05 21:10  chenxiaojian  阅读(166)  评论(0编辑  收藏  举报