(1) There are many times a <result> can be used for many <action>, at this time can use <global-results> tags to define the global <result> Code See Struts-user.xml. Execution order: When a string returned by an action does not correspond to the corresponding <result>, STRUTS2 will find the global <result>.
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE Struts Public
"-//apache software foundation//dtd Struts Configuration 2.0//en"
"Http://struts.apache.org/dtds/struts-2.0.dtd" >
<struts>
<constant name= "Struts.devmode" value= "true"/>
<package name= "user" namespace= "/user" extends= "Struts-default" >
<global-results>
<result name= "MainPage" >/main.jsp</result>
</global-results>
<action name= "Index" >
<result>/index.jsp</result>
</action>
<action name= "user" class= "com.bjsxt.struts2.user.action.UserAction" >
<result>/user_success.jsp</result>
<result name= "Error" >/user_error.jsp</result>
</action>
</package>
Note: If you need to use this global result set in other packages, you need to use the extends
<package name= "admin" namespace= "/admin" extends= "User" >
<action name= "admin" class= "com.bjsxt.struts2.user.action.AdminAction" >
<result>/admin.jsp</result>
</action>
</package>
</struts>