读书人

Struts2.1 处置未知Action 和访问不存

发布时间: 2012-07-24 17:47:58 作者: rapoo

Struts2.1 处理未知Action 和访问不存在的页面
你可以配置个默认action,当请求的action不存在时,他就会去找默认的action

<default-action-ref name="index"></default-action-ref>          <action name="index">              <result>/default.jsp</result>          </action>  




Struts.xml配个全局的 如
<global-results>   <result name="exception" type="dispatcher">/exception.jsp</result>   </global-results> 


Action Default    Usually, if an action is requested, and the framework can't map the request to an action name, the result will be the usual "404 - Page not found" error. But, if you would prefer that an omnibus action handle any unmatched requests, you can specify a default action. If no other action matches, the default action is used instead.    <package name="Hello" extends="action-default">     <default-action-ref name="UnderConstruction">     <action name="UnderConstruction">     <result>/UnderConstruction.jsp</result>     </action>  

读书人网 >互联网

热点推荐