Struts2的通配符的使用

版权声明:博客知识产权来源命运的信徒,切勿侵权 https://blog.csdn.net/qq_37591637/article/details/84940364

为什么用通配符?

如果在配置action的时候发现都是重复的操作,如下所示,这里是两个,如果是n个类似的呢?,就不好管理了。


<action name="login" class="cn.com.action.StrutsDemo" method="login">
<result name="login">/login.jsp</result>
</action>
<action name="exit" class="cn.com.action.StrutsDemo" method="exit">
<result name="exit">/exit.jsp</result>
</action>

通配符的话,就会这样

<action name="*" class="cn.com.action.StrutsDemo" method="{1}">
<result name="{1}">/{1}.jsp</result>
</action>

通配符的规律如下:

1、最精确的配置优先匹配

2、如果都是通配符的情况下,匹配顺序上最早的

猜你喜欢

转载自blog.csdn.net/qq_37591637/article/details/84940364