Result can set the global result set, such as:
<strus> <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"> <result>/user_success.jsp</result> <result name="error">/user_error.jsp</result> </action> </package> <package name="admin" namespace="/admin" extends="user"> <action name="admin"> <result>/admin.jsp</result> </action> </package> </struts>
in
<global-results> <result name="mainpage">/main.jsp</result> </global-results>
It is the set global result set. In this way, as long as the result in all user packages returns "mainpage", they will jump to the main.jsp page. It has many uses. The most common use is to jump to the home page or error page when the user fills in the url error. So how do you also use global result sets in other packages?
As above
<package name="admin" namespace="/admin" extends="user"> <action name="admin"> <result>/admin.jsp</result> </action> </package>
This is the inheritance relationship of the package. The admin package inherits from the user package, so it has all the attributes under the user package. This is very useful. When we have many public pages that need to be displayed, we can use a package as the parent class package of these packages to write these public results into it. Other packages only need to inherit this package.
The above is all the content of using Result to configure the global result set in Struts2. I hope you can give you a reference and I hope you can support Wulin.com more.