版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/G66565906/article/details/83743251
在Struts2使用 struts.xml来配置action时,
action的xml节点基本格式如下所示:
<action name="login" class="com.test.login">
<result name="success">/index.jsp</result>
</action>
此时,当在浏览器端发送请求 http://localhost:8080/XXX/login 时
执行的时com.test.login.execute方式
那么当需要com.test.login类响应不同的 action请求时,则需使用 <action> 的method属性
<action name="login" class="com.test.login" method="method1">
...
</action>
<action name="regist" class="com.test.login" method="method2">
...
</action>
此时,当在浏览器端发送请求 http://localhost:8080/XXX/login 时 会执行com.test.login.method1方法
而发送请求 http://localhost:8080/XXX/regist时 会执行com.test.login.method2方法