• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
第二天半
博客园    首页    新随笔    联系   管理    订阅  订阅

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>

  

posted @ 2014-12-30 23:10  第二天半  阅读(155)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3