Struts2学习之旅(4)

92 阅读1分钟

Struts2学习之旅(4)–默认Action

当我们的请求action没有找到对应的Action就会404
这里写图片描述

我们要在配置文件中添加一个默认的Action, 但找到对应的action
就执行这个默认的Action中的result中的页面
<default-action-ref>
中的name要和action中的name一致,
index

<!-- 添加默认action -->
        <default-action-ref name="index"></default-action-ref>
        <action name="index">
            <result>/error.jsp</result>
        </action>

默认action页面