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>  

猜你喜欢

转载自huguifuture.iteye.com/blog/1199140