Struts2的Action名称搜索顺序:2014.12.30

struts.xml配置:

<struts>
	<package name="hw" namespace="/test" extends="struts-default">
		<action name="helloworld" class="com.self.action.HelloWorldAction" method="dohelloworld">
			<result name="doresult">
				/WEB-INF/actionpage/showresult.jsp
			</result>
		</action>
	</package>
</struts>

正确访问路径:http://localhost:8080/Struts2_01/test/helloworld

如果浏览器访问路径:

先访问路径:“http://localhost:8080/Struts2_01/test/aa/bb/cc/dd/helloworld”没找到!

再访问路径:“http://localhost:8080/Struts2_01/test/aa/bb/cc/helloworld”也没找到!
...... 直到路径:“http://localhost:8080/Struts2_01/test/helloworld”找到了,返回界面显示

  

如果还找不到:就到默认<package></package>里面找

<!-- 默认配置:namespace属性为空 -->
<package name="hw" namespace="" extends="struts-default">
	<action name="helloworld" class="com.self.action.HelloWorldAction" method="dohelloworld">
		<result name="doresult">
			/WEB-INF/actionpage/showresult.jsp
		</result>
	</action>
</package>

  

原文地址:https://www.cnblogs.com/zjsy/p/4194779.html