struts2 05 action通配符

来源:互联网 发布:淘宝商城865药店 编辑:程序博客网 时间:2024/05/01 22:48

实现动态访问还可以通过通配符

eg:

<action name="user*" class="pack.manager" method="{1}">    

<result >/success_{1}.jsp</result>

</action>

当访问时 如果输入 http://localhost:8080/Demo/userAdd

就会匹配到这个action。这时*就匹配为Add  后面method的1的意思是第一个星号,所以 也就是等于 method="Add"

下面同理。即 success_Add.jsp。 

这样可以实现动态访问。

比如 访问换成 http://localhost:8080/Demo/userDel   就会去调用manager类中的Del方法。返回的页面也变为succes_Del.jsp

这样不用更改action实现了动态访问。

0 0