Result can be set globally, such as:
<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>
<package name= "admin" namespace= "/admin" extends= "User" >
<action name= "admin" class= "com.bjsxt.struts2.user.action.AdminAction" >
<result>/ admin.jsp</result>
</action>
</package>
which
<global-results>
<result name= "mainpage" >/main.jsp</result>
</global-results>
Is the set of global result set, in this way, all the user package results as long as the return "MainPage", will jump to the main.jsp page, it uses a lot, the most common is the user fill in the URL error, jump to the homepage or error page. So how do you use a global result set under other packages?
As above the
<package name= "admin" namespace= "/admin" extends= "user" >
<action name= "admin" class= Com.bjsxt.struts2.user.action.AdminAction ">
<result>/admin.jsp</result>
</action>
This is the inheritance relationship of the package, the admin package inherits from the user package, so he has all the attributes under the user bundle, which is very handy, and when we have a lot of public pages to display, we can write them into the parent package of these packages, and we'll put these public result into it, Other packages simply inherit this package.
The above is STRUTS2 use result to configure the entire content of the global results set, I hope to give you a reference, but also hope that we support the cloud habitat community.